how to ease conditions?

2 views (last 30 days)
Ani Asoyan
Ani Asoyan on 11 May 2020
Commented: Ani Asoyan on 11 May 2020
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)
how can I write that easily and short, without typing all the rows and colums?

Accepted Answer

Image Analyst
Image Analyst on 11 May 2020
Try ismember()
if ismember(gov, gp(:, 1:5))
d = d + 1;
  1 Comment
Ani Asoyan
Ani Asoyan on 11 May 2020
Thank you so much !

Sign in to comment.

More Answers (0)


Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!