필터 지우기
필터 지우기

help on if statement

조회 수: 1 (최근 30일)
Abra dog
Abra dog 2011년 11월 1일
How can I use a if loop to display where X4(n,1)>X4(n,2)>X4(n,3)>X4(n,4)>X4(n,5) == 1 n = 1:31 I want it to show where this is true in the matrix or should i use a while loop?
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 12월 8일
There is no such thing as an if loop.

댓글을 달려면 로그인하십시오.

채택된 답변

Honglei Chen
Honglei Chen 2011년 11월 1일
You can vectorize this in one command:
idx = 1:31;
find( (X4(idx,1)>X4(idx,2))&(X4(idx,2)>X4(idx,3))&(X4(idx,3)>X4(idx,4))&(X4(idx,4)>X4(idx,5))&(X4(idx,5)==1))
HTH
  댓글 수: 2
Abra dog
Abra dog 2011년 11월 1일
It says Empty matrix: 0-by-1
Abra dog
Abra dog 2011년 11월 1일
Never mind found out what i was doing wrong with your command. I don't need to put ==1 at the end. Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (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