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:
put result into matrix

Subject: put result into matrix

From: John Wong

Date: 14 Oct, 2009 02:46:07

Message: 1 of 2

Hi I have a question. Let say I have the followings

n = input('Number');
for r = 0:1:n
P = r / 2

now I want to plot a bar graph, or any graph. I have the followings
bar(r,P)

however, P is not in its vector form.
So the output is just
P = 0
P = 1/2
P = 1
P = 3/2
and so on until the max (n)

How would I make them into matrix form?
V = P
V = [0 1/2 1 3/2 ..... n]

Thanks for the help.

Subject: put result into matrix

From: Darren Rowland

Date: 14 Oct, 2009 03:44:18

Message: 2 of 2

You can simply replace

> n = input('Number');
> for r = 0:1:n
> P = r / 2

with

n = input('Number');
P = (0:n)/2;

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