MATLAB: Help changing 0 to 1 based on 2 different criteria

if statementzeros

I'm very new with MATLAB so this may be a real easy question but i've tried a few things and come up with nothing.
A = zeros(size(data));
A(B > C) = 1;
A(B < C) = -1;
All works okay, however I want to put in a second critiera,so bascially like this:
A = zeros(size(data));
A((B > C) & (D < E)) = 1;
A((B < C) & (D > E)) = -1;
However, this doesn't work : (
I'm guessing I could do it with an IF statement, but would really like to know how to just develop this method.
Thanks for you help

Best Answer

  • A(B>C&D<E)=1;