display result (numbers)

3 ビュー (過去 30 日間)
Nadya
Nadya 2020 年 6 月 30 日
コメント済み: Nadya 2020 年 7 月 2 日
Hello,
I have a problem in displaying result.
I have this equation :
ps1=((max(max(X1))-mean(mean(X2)))/ (std2(X2)));
Normally, the result is for example '7.473958' but it is displayed '8' !!!
what is the problem please ?

採用された回答

Steven Lord
Steven Lord 2020 年 6 月 30 日
When you take the max of an integer array, the result is of the same integer type.
When you take the mean of an integer array, the result is (by default) double precision.
When you perform arithmetic on an integer array and a scalar double precision value, the result is of the integer type. See the "Arithmetic Operations on Integer Classes" section on this documentation page.
Convert the output of max from an integer type to double using the double function before you subtract the mean from it.
  1 件のコメント
Nadya
Nadya 2020 年 7 月 2 日
Thank you so much ! problem solved !

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

その他の回答 (1 件)

Rafael Hernandez-Walls
Rafael Hernandez-Walls 2020 年 6 月 30 日
intent with the format command
format long
  1 件のコメント
Nadya
Nadya 2020 年 6 月 30 日
Thank you for your answers
I tried this, but this is not the problem, because in the same program, I calculated other parameters, and they are displayed with the real long format. Just for this parameter, the results are converted and displayed in integer numbers (uint8).

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by