Hi,I have numerical matrix 4X4, I have to classify numbers in grades like less than 20, greater than 20 and less than 20, so Hhow can I do it?
이전 댓글 표시
I have numerical matrix 4X4, I have to classify numbers in grades like less than 20, greater than 20 and less than 20, so how can I do it?
채택된 답변
추가 답변 (1개)
Jack Breenlair
2015년 10월 16일
편집: Jack Breenlair
2015년 10월 16일
You want to use two for loops that go through the matrix checking if the numbers satisfy the conditions that you require.
auxiliar=0;
for i=1:4
for j=1:4
if A(i,j)==condition
auxiliar=auxiliar+1;
end
end
end
something like this
댓글 수: 3
Guillaume
2015년 10월 16일
The code above can be reduced simply to:
auxiliar = nnz(A == condition);
No need for loops.
Anup Badve
2015년 10월 16일
Anup Badve
2015년 10월 16일
카테고리
도움말 센터 및 File Exchange에서 Classification Trees에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!