How in Matlab?
조회 수: 9 (최근 30일)
이전 댓글 표시
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
채택된 답변
Star Strider
2015년 9월 16일
I’m not certain what you want. See if this works:
A=[1 2 3;4 5 6;7 8 9];
A(A(1,:)>0) = 1;
It tests the first column in every row, and if it is positive, replaces it with 1.
댓글 수: 2
Star Strider
2015년 9월 16일
You have to put parentheses in the subscript references:
A(A(1,:)>0) = 1;
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!