Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
putting same elements in a vector

Subject: putting same elements in a vector

From: Christopher

Date: 26 May, 2011 22:47:04

Message: 1 of 5

I have a problem that says "using the colon symbol, create a vector with eleven elements that are all 4." I'm not sure how to use the colon symbol to get the right answer. Please help!

Subject: putting same elements in a vector

From: Florin Neacsu

Date: 26 May, 2011 23:59:06

Message: 2 of 5

"Christopher " <cpeyatt1@mix.wvu.edu> wrote in message <irml98$g2m$1@newscl01ah.mathworks.com>...
> I have a problem that says "using the colon symbol, create a vector with eleven elements that are all 4." I'm not sure how to use the colon symbol to get the right answer. Please help!

Hi,

Depends how "arrogant" you want to be, as the problem hasn't set to many boundaries.

One of the many ways

B=4*ones(11);

myVector = B(1,:)

Regards,
Florin

Subject: putting same elements in a vector

From: ImageAnalyst

Date: 27 May, 2011 02:48:17

Message: 3 of 5

I shouldn't be doing your homework for you either but I'll give you
one more idea.

m = int32(4 : 0.01 : 4.1)

Of course there are tons of ways to do it, so pick your own (not mine)
to turn in, now that you have two hints from the two of us.

Subject: putting same elements in a vector

From: Roger Stafford

Date: 27 May, 2011 04:22:05

Message: 4 of 5

"Christopher " <cpeyatt1@mix.wvu.edu> wrote in message <irml98$g2m$1@newscl01ah.mathworks.com>...
> I have a problem that says "using the colon symbol, create a vector with eleven elements that are all 4." I'm not sure how to use the colon symbol to get the right answer. Please help!
- - - - - - - - - -
  How about 4*(1:11)./(1:11) ?

Roger Stafford

Subject: putting same elements in a vector

From: Donald

Date: 27 May, 2011 05:25:20

Message: 5 of 5

"Christopher " <cpeyatt1@mix.wvu.edu> wrote in message <irml98$g2m$1@newscl01ah.mathworks.com>...
> I have a problem that says "using the colon symbol, create a vector with eleven elements that are all 4." I'm not sure how to use the colon symbol to get the right answer. Please help!



An easy way:

xTemp(1:11) = 4

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us