Find Maximum one of numerical arguments

How can i find max of 30 arguments max(H1,H2.....H30)
But error message occured "Error using max Too many input arguments.MAX with two matrices to compare and a working dimension is not supported"
Is there any other way?

 Accepted Answer

Image Analyst
Image Analyst on 27 May 2013
Edited: Image Analyst on 27 May 2013
Put brackets around them to make them a single array, as my answer below shows.
Try this:
[maxValue, indexAtMaxValue] = max([H1, H2, H3, H4, ...ETC...... , H29, H30]);

7 Comments

Sorry can't found right answer.
maxValue =
0
indexAtMaxValue =
1
I'm trying to find it.
max(H1,H2.....H30)<0.0001
You've given no evidence that this is wrong.
while true
......
.......
if
max(H01,H12,H23,H14,H45,H56,H47,H77,H78,H89,H910,H811,H1112,H1113,H1314,H1315,H1516,H1617,H1618,H1819,H1520,H2021,H2022,H2223,H2224,H2425,H2426,H2627,H2628,H2829)<0.001;
break;
end;
end
Image Analyst
Image Analyst on 27 May 2013
Edited: Image Analyst on 27 May 2013
You forgot to give us the values for the H's, so we can't try my answer. By the way, I didn't say "max(...)<0.001" as you did. Plus you didn't put brackets around them like I told you to.
[maxValue, indexAtMaxValue]=max([H01,H12,H23,H14,H45,H56,H47,H77,H78,H89,H910,H811,H1112,H1113,H1314,H1315,H1516,H1617,H1618,H1819,H1520,H2021,H2022,H2223,H2224,H2425,H2426,H2627,H2628,H2829]);
Result:
maxValue =
0
indexAtMaxValue =
1
H values less than 0.01.... What will i do
Once again: You forgot to give us the values for the H's, so we can't try my answer.
To drive the point home: How on earth am I supposed to know what value H01 takes on? Or what value any of the other variables have? The answer is I don't. Unless you supply them to me. GIVE ME CODE THAT SAYS:
H01 = 0.003342243423; % or whatever.
...
H2022 = 0.233423423423; % or whatever.
and so on, for all the H's.
So sorry!! My CODE is almost 500 rows and all of it relative and it is changed in next iterations .......
Anyway!!! Thanks for your big help :-))))

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!