Fill a matrix after an iteration

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by