Help shifting a movmedian plot along the x-axis

조회 수: 1 (최근 30일)
Jack Radcliffe
Jack Radcliffe 2020년 5월 3일
답변: Sai Sri Pathuri 2020년 5월 6일
Hi, I am having an issue in moving a movmedian plot to align with a line graph, which are very far apart on the x-axis. I have tried a few methods and have been able to move the y axis, but not the x yet for the movmedian. Here is my code:
t = 1:4656;
x = datenum(2006, 01, 01) + t;
str = datestr(x, 'mmm yyyy');
plot(x, Don)
hold on
tick_locations = datenum(2006,01:6:153,1);
set(gca,'XTick',tick_locations);
datetick('x','mmm yyyy','keeplimits', 'keepticks');
set(gca,'XTickLabelRotation',45)
set(gca,'XMinorTick','off','YMinorTick','on')
grid minor;
and the plot im trying to align it with is:
plot(movmedian(Don,7))
I tried calling q = to the above plot and managed to move the y axis up and down:
plot(movmedian(Don,7))
>> hold on
>> plot(t+5,q)
although im unsure how to change this to apply to the x-axis. I've also tried applying the tick_locations for the movmedian plot from my initial plot but this doesnt work.
Any help is greatly appreciated.

답변 (1개)

Sai Sri Pathuri
Sai Sri Pathuri 2020년 5월 6일
The difference in the x locations might be because you are not plotting movmedian(Don,7) against x. You may try the following to overlap both the plots.
plot(x,movmedian(Don,7))

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by