plot for different value of movmean(X,k) with a for loop

2 views (last 30 days)
Hi!! I have to create a graphs using this function movemean(X,k) where X is my vector for example Y=[1;2;4;5;6] and k is the rate that I would like to change. Infact, I would like to create a subplot with a different value of k. I make this: subplot(2,1,1),plot(movmean(e,2),movmean(sigma,2)),grid subplot(2,1,2),plot(movmean(e,5),movmean(sigma,3)),grid subplot(2,1,3),plot(movmean(e,5),movmean(sigma,4)),grid subplot(2,1,4),plot(movmean(e,5),movmean(sigma,5)),grid But I would like to make with a for loop, without changing manually the value of k. thanks for your help

Answers (1)

Jan
Jan on 30 May 2018
If you want a loop, use a loop:
for k = 1:4
subplot(2,1,k);
plot(movmean(e, k + 1), movmean(sigma, k + 1))
grid('on');
end

Categories

Find more on MATLAB 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!