how can i choose a certain row from simulation?

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
arkedia
arkedia il 16 Gen 2013
Modificato: Jan il 16 Gen 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 il 16 Gen 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.

Accedi per commentare.

Risposta accettata

José-Luis
José-Luis il 16 Gen 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];

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by