print the element of a matrix
Show older comments
i wrote this code to print the largest element in the first row of a matrix, but it print the index of the largest number?
how cam i print largest element??
matrix=input("Enter the Matrix");
max=0;
[r,c]=size(matrix);
d=c[j];
n=length(matrix);
for i=0:1
for j=0:c
if [j]> max
max=[j];
end
end
end
disp(max);
Accepted Answer
More Answers (1)
Stijn Haenen
on 17 May 2020
a=-Inf;
for i=1:numel(matrix(:,1))
if matrix(i,1)>a;
a=matrix(i,1);
end
end
disp(a)
1 Comment
mohammed almakaleh
on 17 May 2020
Edited: mohammed almakaleh
on 17 May 2020
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!