Problem using max function on relatively large arrays

1 回表示 (過去 30 日間)
Giulia Buraglio
Giulia Buraglio 2018 年 5 月 23 日
編集済み: Stephen23 2018 年 5 月 23 日
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 件のコメント
Stephen23
Stephen23 2018 年 5 月 23 日
編集済み: Stephen23 2018 年 5 月 23 日
@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:

サインインしてコメントする。

回答 (1 件)

Guillaume
Guillaume 2018 年 5 月 23 日
編集済み: Guillaume 2018 年 5 月 23 日
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)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by