Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Question about plotting time series graph in Matlab
1 回表示 (過去 30 日間)
古いコメントを表示
Hi!
I need to plot pictures like the ones attached to this question. I started with Matlab's subplotting commands. But, I am not being able to find the correct answer. I am becoming mad over this for about a week. I would be glad if someone could help me.
2 件のコメント
Image Analyst
2020 年 7 月 5 日
Sure, we'll help you. How can we help? I mean there is the plot() function but I'm sure you've already learned about that and tried it, so how else can we help you? I guess you just clicked past the instructions that were there when you posted the questions, so now you should read this link before fixing your post which will enable us to answer.
回答 (2 件)
Image Analyst
2020 年 7 月 5 日
Doesn't this look kind of like your image?
t1 = datetime(1971,1,1,8,0,0);
t2 = datetime(2017,1,1,8,0,0);
t = t1 + calmonths(1:46*12)
numPoints = length(t)
y_t = movmean(20 * rand(1, numPoints) - 10, 51);
plot(t, y_t, 'b-', 'LineWidth', 2);
grid on;
xlabel('Date', 'FontSize', fontSize);
ylabel('y_t', 'FontSize', fontSize, 'Interpreter', 'none');
datetick('x', 'mm/dd/yyyy');
ax = gca;
ax.XTickLabelRotation = 90;
3 件のコメント
Image Analyst
2020 年 7 月 6 日
編集済み: Image Analyst
2020 年 7 月 6 日
You keep forgetting to attach muja in a .mat file, which means you ignored my advice to read this link.
TUTORIAL: how to ask a question (on Answers) and get a fast answer - MATLAB Answers - MATLAB Central
Too bad. I'll check back later. Also when you post code, highlight the code and click the Code icon so that people can copy it to the clipboard with one click.
In the meantime, this throws no error:
numQuarters = 54;
muja = rand(numQuarters * 4, 2);
ea = muja(:,1);
state= muja(:,2);
t1 = datetime(1966,4,1);
t2 = datetime(2020,1,1);
t = t1 + calquarters(1:54*4)
numPoints = length(t)
% subplot1 = subplot(3,3,1,'Parent',figure);
% hold(subplot1,'on');
whos t, whos ea
plot(t,ea,'b-','linewidth',2);
grid on;
xlabel('Date', 'FontSize', fontSize);
ylabel('ea', 'FontSize', fontSize, 'Interpreter', 'none');
xlim([t1, t2]);
% xticks(t1 : caldays(30) : t2);
datetick('x', 'mm/dd/yyyy');
ax = gca;
ax.XTickLabelRotation = 90;
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!