Calculate Mean of vector in more decimals
Show older comments
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
Accepted Answer
More Answers (1)
Image Analyst
on 3 Jun 2024
Edited: Image Analyst
on 3 Jun 2024
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
Categories
Find more on Descriptive Statistics and Insights in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!