Calculate Mean of vector in more decimals
10 次查看(过去 30 天)
显示 更早的评论
I want to calculate the mean of a vector in more than 4 decimals. The code
A = [0,1,9];
mean(A)
gives
ans = 3.3333
But I want 3.333333
0 个评论
采纳的回答
Michael
2024-6-3
3.3333 is only the display of the variable 'ans'. The result of the calculation has better accuracy. Type
format long
and you can see the result with all significant decimals.
0 个评论
更多回答(1 个)
Image Analyst
2024-6-3
编辑:Image Analyst
2024-6-3
It is already that.
A = [0,1,9];
format short g
m = mean(A)
fprintf('Mean with 30 decimal places is %.30f.\n', m);
format long g
m = mean(A)
and
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Filename Construction 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!