Why wont it output index?
Ältere Kommentare anzeigen
function[max,index]=MyMax(x)
max=0;
[n,m]=size(x);
for i=1:m
if max<x(i)
max=x(i);
index=i;
output = [max, index];
end
end
end
Akzeptierte Antwort
Weitere Antworten (1)
Sulaymon Eshkabilov
am 9 Okt. 2019
Bearbeitet: Sulaymon Eshkabilov
am 9 Okt. 2019
Just use:
[MAX_VAL, INDEX] = min(x) % instead of max()
Good luck.
1 Kommentar
Hunter Steele
am 9 Okt. 2019
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!