help-octave
[Top][All Lists]
Advanced

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

If statement


From: A . M . Zainal-Abidin
Subject: If statement
Date: Thu, 15 Oct 2009 14:41:43 +0100


 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


reply via email to

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