help-octave
[Top][All Lists]
Advanced

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

Re: If statement


From: Søren Hauberg
Subject: Re: If statement
Date: Thu, 15 Oct 2009 16:14:21 +0200

tor, 15 10 2009 kl. 10:09 -0400, skrev James Sherman Jr.:
> 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;

You should initialise 'w1' to a vector with the same size as
'weeklyaverage1', i.e.

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

Søren



reply via email to

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