필터 지우기
필터 지우기

Fill a matrix after an iteration

조회 수: 3 (최근 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 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