Problem using max function on relatively large arrays

1 visualizzazione (ultimi 30 giorni)
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 Commento
Stephen23
Stephen23 il 23 Mag 2018
Modificato: Stephen23 il 23 Mag 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:

Accedi per commentare.

Risposte (1)

Guillaume
Guillaume il 23 Mag 2018
Modificato: Guillaume il 23 Mag 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)

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Tag

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by