plot(v,cumsum(v)./(1:numel(v)))
plot mean of vector v(1:i)
1 次查看(过去 30 天)
显示 更早的评论
For simplicity, I have the following code
v=1:10;
for i=1:10
mean_v(i) = mean(v(1:i));
end
plot(v,mean_v)
In essence, I want to plot the mean of the vector from elements 1 to i, as a function of the i-index. Any way I could do it in one line?
plot(v,mean(v(1:?)))
What should I change in the mean(v(1:?)) part?
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!