フィルターのクリア

how can i deal with empty matrix: 0-by-any number resulting from simulation???

1 回表示 (過去 30 日間)
arkedia
arkedia 2013 年 2 月 3 日
I have made a simulation and the result each time of the simulation is a matrix and i choose a certain row from the matrix, so if the simulation run=500, i'll have a 500 matrix and ,the row i choose each time will be (at the end of the simulation) 500 rows [one row from the first matrix...last row from the last matrix]... the problem is some times a matrix dose not contain the certain row i want , the answer is for example empty matrix: 0-by-6 i want to ignor this answer Note: the row i choose is not necessary to be exist in all matrices so if the run=600 , result in 600 matrix , the row i choose maybe =400 only and the other 200 will be zero the simulation STOP when the result is empty matrix: 0-by-any number i use Matlab
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 3 日
Can you provide an example?
arkedia
arkedia 2013 年 2 月 5 日
for example: the first matrix from simulation=[18 1 0 0 0;12 0 0 0 1;15 1 1 0 0] and the second matrix from simulation=[25 0 0 0 0;30 1 1 0 0;14 0 0 1 0] and the thierd matrix from simulation=[50 1 0 0 0;12 0 0 1 0;24 1 1 1 0] I used the following function ::::::::::::::::::: idxfun=@(x)find(ismember(x(:,2:end),[1 0 0 0],'rows'))::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::: a=the first matrix(idxfun(the first matrix),:)the answer is as follows: 18 1 0 0 0 the second matrix answer is:: empty matrix:0-by-5 then the simulation stop!! what i want is to make the simulation continue and go to the next matrix and in this example the answer will be 50 1 0 0 0

サインインしてコメントする。

採用された回答

Shashank Prasanna
Shashank Prasanna 2013 年 2 月 3 日
Have tried ISEMPTY, you can check if a matrix is empty and then discard it or proceed as required.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeneral Applications についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by