# How to find the maximum element among the minimum elements in the columns in matrix m:n? With using loops.

1 vue (au cours des 30 derniers jours)
Ksenia Kolobaeva le 25 Mar 2020
Commenté : Guillaume le 25 Mar 2020
It seemed simple from the beginning, but I got confused. Can anyone show a script that will do this?
##### 2 commentairesAfficher AucuneMasquer Aucune
Alex Mcaulley le 25 Mar 2020
What have you tried?
Ksenia Kolobaeva le 25 Mar 2020
% % so... I started like this:
n = input(num2str('Rows: ', 's'));
m = input(num2str('Columns ', 's'));
massive = round(100+(200-100)*rand(n,m));
disp(massive)
for i = 1:m
strr = massive(:,i);
for j = 1:n
% % And there should be a function that compares the elements, selects the minimum in the column and then compares which one is the maximum. I can't figure out what it should be.
end
end

Connectez-vous pour commenter.

### Réponses (1)

Guillaume le 25 Mar 2020
There's never any need for a loop for things like that. Loops usually complicate the code in matlab.
maxofcolmin = max(min(massive, [], 2)); %return the maximum of the minimum across the columns of massive
##### 2 commentairesAfficher AucuneMasquer Aucune
Ksenia Kolobaeva le 25 Mar 2020
Thank you! I know that all can be done shortly and simply. But the task requires the use of loops, and this is the problem.
Guillaume le 25 Mar 2020
Oh, it's some homework. I'm afraid you'll have to work it out yourself. It's not that hard. Keep track of your current minimum/maximum. Compare your element to that and if it is smaller/greater replace the current value.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

R2019b

### Community Treasure Hunt

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

Start Hunting!

Translated by