Cumulative Mean of a Matrix
9 views (last 30 days)
Show older comments
Hi,
I have a matrix: Vx=[4,5,6,3,2,4,5,6,4,3,2,5,6,7,5] etc.
I want to find the cumulative mean of these values (to see if the velocity field converges with time).
Does anyone have a good method to do this?
I have
for k=1:1:15;
CumuVel=mean(Vx(1,1):Vx(1,k));
end
But this won't work....any suggestions?
Thanks
3 Comments
Teja Muppirala
on 2 Nov 2012
I agree with Image Analyst, to see if something is converging, it is not sufficient to just look at the cumulative mean.
For example, this series Vx is diverging, but the cumulative mean still converges:
Vx = sqrt(1:1000) .* (-1).^(1:1000)
plot(Vx); % Clearly not converging
CumuVel = cumsum(Vx)./(1:length(Vx)); % Get cumulative mean
figure, plot(CumuVel); % Vx is diverging, this is converging
Jan
on 2 Nov 2012
I assume, you mean:
CumuVel = zeros(1, 15); % Pre-allocation!!!
for k = 1:15;
CumuVel(k) = mean(Vx(1:k));
end
Answers (1)
See Also
Categories
Find more on Axis Labels 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!