How to use if statement with an array

4 ビュー (過去 30 日間)
Nicholas Wills
Nicholas Wills 2017 年 3 月 19 日
回答済み: Star Strider 2017 年 3 月 19 日
I want to find out if an array equals a particular set of values, as follows:
if arrayName=[0 1 1 0]
do this
end
And so on, MATLab throws up an error saying it expects a scalar value. Am I using the brackets wrong, or is this something that cannot be done? (I am quite new to MATLab).
Cheers, Nick

採用された回答

Star Strider
Star Strider 2017 年 3 月 19 日
There are several set functions that could apply to your problem. One that comes quickly to mind is ismember with the 'rows' option.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by