error from 'and' statement

2 views (last 30 days)
David
David on 20 Nov 2014
Commented: David on 20 Nov 2014
Hi so I'm kinda new to using logic statements with MATLAB,
I am looping through a matrix of data, and seeing whether or not each value fits falls within a needed range, so I've tried using an AND statement within a for loop being:
if AND(data_reshape_3(count1, count2) > 0, data_reshape_3(count1, count2) <= 0.5);
However I am getting this error:
Undefined function 'AND' for input arguments of type 'logical'.
Any advise?
Thanks

Accepted Answer

Adam
Adam on 20 Nov 2014
Edited: Adam on 20 Nov 2014
You should use && or & to AND together two statements, depending on whether or not the individual statements evaluate to scalars or matrices.
e.g.
data_reshape_3(count1, count2) > 0 && data_reshape_3(count1, count2) <= 0.5
If you want to call the function though you have to use lowercase:
and( data_reshape_3(count1, count2) > 0, data_reshape_3(count1, count2) <= 0.5 )
  1 Comment
David
David on 20 Nov 2014
thanks, the lower case worked spot-on :)

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!