arg max data type
1 回表示 (過去 30 日間)
古いコメントを表示
Take the following example
x = single(-(-2:2).^2);
[xm,ix]=max(x);
whos
I think it strange that variable ix is of type double, and not integer, which would be the most logical alternative.
Anyway, I am using this kind of line for a code generation case, where double data type is banned.
Is there any way I can force max function to return an integer value for argmax (variable ix in code above)?
1 件のコメント
Steven Lord
2022 年 5 月 13 日
I think it strange that variable ix is of type double, and not integer, which would be the most logical alternative.
I suspect that the two-output form of max predates the introduction of the integer data types to MATLAB.
採用された回答
Matt J
2022 年 5 月 13 日
No, but can't you just cast it to an integer type post-facto? E.g.,
ix=cast(ix,'uint32');
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!