Ältere Kommentare anzeigen
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 Kommentare
James Tursa
am 16 Sep. 2015
Please provide a short example of inputs and desired outputs.
Mario Marinov
am 16 Sep. 2015
Akzeptierte Antwort
Weitere Antworten (1)
Mario Marinov
am 16 Sep. 2015
3 Kommentare
Star Strider
am 16 Sep. 2015
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
am 16 Sep. 2015
Star Strider
am 16 Sep. 2015
My pleasure!
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!