Filter löschen
Filter löschen

how can i choose a certain row from simulation?

1 Ansicht (letzte 30 Tage)
arkedia
arkedia am 16 Jan. 2013
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 Kommentare
arkedia
arkedia am 16 Jan. 2013
Bearbeitet: Jan am 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 am 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

José-Luis
José-Luis am 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];

Weitere Antworten (0)

Kategorien

Mehr zu App Building finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by