Why wont it output index?
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Sulaymon Eshkabilov
2019년 10월 9일
편집: Sulaymon Eshkabilov
2019년 10월 9일
Just use:
[MAX_VAL, INDEX] = min(x) % instead of max()
Good luck.
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!