help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: If statement


From: James Sherman Jr.
Subject: Re: If statement
Date: Thu, 15 Oct 2009 10:09:00 -0400

I think that your if/elseif statements should be testing weeklyaverage1(i) not weeklyaverage1.  Though you can actually do this without the for loop at all by doing something similar to what you (possibly mistakenly) are doing now.

w1 = 0.75;
w1(weeklyaverage1>=80) = 1;
w1(weeklyaverage1<=75) = 0;

I think would do what you are looking to do without the need for the for loop.

On Thu, Oct 15, 2009 at 9:41 AM, <address@hidden> wrote:

 Hello,

I am trying to create a stem plot for  integers  ranging
from 75 to 81. I tried using the if statements so that if
the integer is equal or larger than 80, the assigned
figure is 1 and if the figure is below or equal to 75,
then the assigned figure is zero. The rest in between will
be assigned 0.75 (or some arbitrary figure). the script is
as below.

%Mould risk for wall 1
w1=linspace(0,1,length((weeklyaverage1));
for i=1:length((weeklyaverage1));
 if (weeklyaverage1>=80)  w1(i)=1;
 elseif (weeklyaverage1<=75)  w1(i)=0;
 else w1(i)=0.75;
 endif
end
figure();
clf;
stem(w1);

However, the stem plot shows that all the figures assigned
at 0.75, meaning all the figures that I have are between
76 and 79. Is my script at fault here? I have tried using
switch statement but the stem plot still shows the same
pattern.

Thank you.

Murad
_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave


reply via email to

[Prev in Thread] Current Thread [Next in Thread]