How in Matlab?
이전 댓글 표시
How to set up a program that introduces a square matrix of numbers from the fourth line? The program should be replaced first positive element in each row 1 and outputting the resulting matrix. Go somewhere and ... Please help!
댓글 수: 2
James Tursa
2015년 9월 16일
Please provide a short example of inputs and desired outputs.
Mario Marinov
2015년 9월 16일
채택된 답변
추가 답변 (1개)
Mario Marinov
2015년 9월 16일
댓글 수: 3
Star Strider
2015년 9월 16일
With those conditions, the code requires a loop and the find function:
A = [-1 2 3;4 -5 6;7 8 -9];
for k1 = 1:size(A,1)
A(k1,find(A(k1,:)>0, 1, 'first')) = 1;
end
Mario Marinov
2015년 9월 16일
Star Strider
2015년 9월 16일
My pleasure!
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!