how to ease conditions?

조회 수: 1 (최근 30일)
Ani Asoyan
Ani Asoyan 2020년 5월 11일
댓글: Ani Asoyan 2020년 5월 11일
Hi .. In my code I have a result number (called "gov") on which I want to put conditions
also there is a matrix with 25 columns and 5 rows (called "gp") and a parameter "d"
if gov= one of the values of the first 5 colums of gp (doesn't matter which row)
d=d+1
end
how can I write that easily and short, without typing all the rows and colums?

채택된 답변

Image Analyst
Image Analyst 2020년 5월 11일
Try ismember()
if ismember(gov, gp(:, 1:5))
d = d + 1;
end
  댓글 수: 1
Ani Asoyan
Ani Asoyan 2020년 5월 11일
Thank you so much !

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by