how can i choose a certain row from simulation?

1 view (last 30 days)
i make a simulation it's results is a matrix so, if the run =500, i'll have 500 matrix my quistion is..........i want to choose certain row from those martrces the row is .....[xxx 1 0 0 0]...note xxx means the existing number it's different from matrix to another
  3 Comments
arkedia
arkedia on 16 Jan 2013
Edited: Jan on 16 Jan 2013
matrix one [18 1 0 0 0;15 1 0 1 0;20 0 0 0 1]
matrix two [30 1 0 0 0;20 1 0 1 0;50 0 1 0 0]
matrix three [10 1 0 1 0;20 1 0 0 0;40 0 0 1 0]
...the new matrix i want consists of [18 1 0 0 0;30 1 0 0 0;20 1 0 0 0]
Jan
Jan on 16 Jan 2013
I do not see the relation between the three input arrays and the output. Please explain the procedure with all required details. Do not use explanations as "matrix one", but the valid Matlab syntax like "A= [...]". It is unclear in which format you store the 500 matrices, but this detail matters.

Sign in to comment.

Accepted Answer

José-Luis
José-Luis on 16 Jan 2013
your_mat = [18 1 0 0 0;...
15 1 0 1 0;...
20 0 0 0 1];
idxFun = @(x) find(ismember(x(:,2:end),[1 0 0 0],'rows'));
your_row = your_mat(idxFun(your_mat),:);
Then you can concatenate:
your_result = [your_row1;your_row2;your_row3];

More Answers (0)

Categories

Find more on App Building 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!