Fill a matrix after an iteration

1 回表示 (過去 30 日間)
luca
luca 2019 年 10 月 7 日
回答済み: darova 2019 年 10 月 7 日
Hi, given the following code:
PPP=[ 18 19 20 13 18 16 19 3 2 3 3 2 2 2 1 2 1 2 1 2 1 4 2 4 2 4 2 4 2 4 8 1 1 1 1 8 4;
18 19 20 13 18 16 19 3 2 3 3 2 2 2 1 8 1 2 1 2 1 4 2 4 2 4 2 4 2 4 8 1 1 1 1 8 4;
18 19 20 13 18 16 19 3 4 3 3 2 2 2 1 8 1 2 1 2 1 4 2 4 2 4 2 4 2 4 8 1 1 1 1 8 2;
18 19 20 13 18 16 19 3 2 3 3 2 1 1 1 2 1 2 1 2 1 4 2 4 2 4 2 4 2 4 8 1 4 8 8 8 4];
nrawD = size (PPP,1);
ncolD = size (PPP,2);
for kk= 1:nrawD;
....
for ii=1:...;
...
TMR(ii,:) = ...; % is an array of 0 and 1.
...
end
end
E=sum(TMR(:) == 1) % find how many 1 are inside TMR
if E > 6
continue
else
TM(kk,:)=TMR; % I want to report the array TMR in the matrix TM just when E<6.
end
end
I want to fill a matrix TM with the arrays TMR that are created at each iteration. But I want to fill TM just with the TMR that has a value of E < 6.
I don't know how but I can't have what I want. Probably the error is here
if E > 6
disp('su')
else
TM(kk,:)=TMR;
end
May someone help me?

採用された回答

darova
darova 2019 年 10 月 7 日
Maybe
TM = (sum(TMR)>6) .* sum(TMR);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePulse and Transition Metrics についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by