Problem using max function on relatively large arrays

1 vue (au cours des 30 derniers jours)
Giulia Buraglio
Giulia Buraglio le 23 Mai 2018
Modifié(e) : Stephen23 le 23 Mai 2018
Hello everyone,
I'm trying to find maximum and minimum value of my vector: power_laboratori (82218 x 1, double), but when I apply both max ad min functions MATLAB gives me as a result a matrix 82218 x 7, containing more ore less the same values I had in my original vector.
the code I used is extremely simple:
Max= max(power_laboratori, 'omitnan');
can someone explain what's happening or what I'm missing?
thank you in advance
  1 commentaire
Stephen23
Stephen23 le 23 Mai 2018
Modifié(e) : Stephen23 le 23 Mai 2018
@Giulia Buraglio: The max syntax that you are using does not do what you think it does: the second argument is interpreted as a seven element vector double('omitnan'). According to the max documentation you should use:
max(power_laboratori, [], 'omitnan')
Read this for an explanation of why the [] argument is required:

Connectez-vous pour commenter.

Réponses (1)

Guillaume
Guillaume le 23 Mai 2018
Modifié(e) : Guillaume le 23 Mai 2018
The proper syntax is:
max(power_laboratori, [], 'omitnan')
The [] is important as 'omitnan' must be the third argument, not the second. At the moment because of implicit expansion you're calculating the maximum of each element of your matrix with the characters of 'omitnan' replicated along the rows. In effect,
Max = [max(pl(1), 'o'), max(pl(1), 'm'), max(pl(1), 'i'), ..., max(pl(1), 't');
max(pl(2), 'o'), max(pl(2), 'm'), max(pl(2), 'i'), ..., max(pl(2), 't');
...
max(pl(82218), 'o'), max(pl(82218), 'm'), max(pl(82218), 'i'), ..., max(pl(82218), 't')]
is what you were calculated (where pl stands for power_laboratori)

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Tags

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by