How to find the maximum value of an matrix without using max function?
3 views (last 30 days)
Show older comments
I need to find maximum value of a matrix but I cannot use max function so I need another way to do it?
1 Comment
Amenson Joseph
on 28 Oct 2020
Amat=randi([-20,20],3,5); %3 x 5 matrix of random integers each in the range from -20 to 20
MatMax=Amat(1,1); %MatMax is the first element of Amat for now.
for k=1:length(Amat(:,1))
for m=1:length(Amat(1,:))
if(Amat(k,m)>MatMax)
MatMax=Amat(k,m);
end
end
end
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices 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!