error from 'and' statement

2 次查看(过去 30 天)
David
David 2014-11-20
评论: David 2014-11-20
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

采纳的回答

Adam
Adam 2014-11-20
编辑:Adam 2014-11-20
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 )

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by