Problem using max function on relatively large arrays
1 回表示 (過去 30 日間)
古いコメントを表示
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
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
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)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Introduction to Installation and Licensing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!