How to use if statement with an array
조회 수: 11 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!