Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Vectors and matrix with repeating elements using colons

14 views
Skip to first unread message

Parker Osborne

unread,
Jun 13, 2011, 11:29:05 AM6/13/11
to
These questions are from an introductory matlab book, and I can't seem to be able to do them.

Using the colon symbol, create a row vector with eleven elements that are all 4.

and

Using the colon symbol, create a 3x5 matrix in which all the elements are the number 7.

I can do it using linspace, but I cant figure out how to use a colon in it.

dpb

unread,
Jun 13, 2011, 1:06:44 PM6/13/11
to
Parker Osborne wrote:

Somebody else apparently was using same text not very long ago...

--

Matt J

unread,
Jun 13, 2011, 1:26:04 PM6/13/11
to
"Parker Osborne" <posb...@mix.wvu.edu> wrote in message <it5ac1$ldg$1...@newscl01ah.mathworks.com>...

> These questions are from an introductory matlab book, and I can't seem to be able to do them.
>
> Using the colon symbol, create a row vector with eleven elements that are all 4.
>
> and
>
> Using the colon symbol, create a 3x5 matrix in which all the elements are the number 7.
=======================

>> A(1:11)=4, B(1:3,1:5)=7

A =

4 4 4 4 4 4 4 4 4 4 4


B =

7 7 7 7 7
7 7 7 7 7
7 7 7 7 7

0 new messages