[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Simple question regarding plotting in for loops
From: |
James Sherman Jr. |
Subject: |
Re: Simple question regarding plotting in for loops |
Date: |
Wed, 20 Feb 2013 22:25:05 -0500 |
On Wed, Feb 20, 2013 at 10:20 PM, Henriamaa <address@hidden> wrote:
> When I write a function for plotting this way:
> function test
> for i =1:10;
> h = sin (i);
> plot(h)
> endfor
>
> it does not plot anything but when I do this:
> function test
> i =1:10;
> h = sin (i);
> plot(h)
> it plots the points.
>
> This is a general pattern. I have been able to draw a circle without the for
> loop but once I put the plot statement in the for loop nothing is plotted.
> What am I doing wrong?
>
>
>
> --
> View this message in context:
> http://octave.1599824.n4.nabble.com/Simple-question-regarding-plotting-in-for-loops-tp4650092.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
In your for loop, you assign h to just one number so,
for i =1:10;
h = sin (i);
plot(h)
endfor
h is just one number, so the loops go something like:
i = 1;
h = sin(1);
plot(h); % just plots the point (1, sin(1))
i = 2;
h = sin(2)
plot(h); % just plots the point (1, sin(2)) on a new plot
and so on.
Hope this helps,
James Sherman