how to find maximum alement

There is a matrix (nXm )
we should write a code that gives the maximum element in the matrix.
it is eligible to use : sort, max, min , for, if ,while or any loops .

1 Comment

I have started the solution but did not know how to continue
any help...
a=size(M);
b=M(1:end);
c=repmat(a,length(a),1);
d=repmat(a',1,length(a));
e=(c-d);
f=M(e>=0);
h=(sum(f));

Sign in to comment.

Answers (1)

max(matrix(:))

7 Comments

I cannot use max , the instructions are not to use max
yeh, I saw but simply It is eligible to use loops in the code.
Image Analyst
Image Analyst on 25 Dec 2018
Edited: Image Analyst on 25 Dec 2018
"eligible" means you CAN do it. Did you mean "ineligible"
The only times we hear people say they cannot use certain functions is if it's their homework. Is this your homework? If it is, then we ethically should not just give you the complete answer. Because usually the professor's assignment is not something like "Have someone else solve this question and turn it in as your own." I think you need to read this link so we can help you in a way you'll feel safe turning in the code.
To find the min or max you either must use loops or use a function. I don't know of any other way off the top of my head.
Me neither..
it is a homework but I do not have any idea how to start the solution, I have tried some ways but they did not work.
I have started the solution in this way, can you help me to continue..
M= is the matrix that we put.
a=size(M);
b=M(1:end);
c=repmat(a,length(a),1);
d=repmat(a',1,length(a));
e=(c-d);
f=(e>=0);
h=sum(f);

Sign in to comment.

Categories

Asked:

on 25 Dec 2018

Commented:

on 25 Dec 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!