Why wont it output index?
Show older comments
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
Accepted Answer
More Answers (1)
Sulaymon Eshkabilov
on 9 Oct 2019
Edited: Sulaymon Eshkabilov
on 9 Oct 2019
Just use:
[MAX_VAL, INDEX] = min(x) % instead of max()
Good luck.
1 Comment
Hunter Steele
on 9 Oct 2019
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!