Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Question about plotting time series graph in Matlab
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Image Analyst
el 5 de Jul. de 2020
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.
Respuestas (2)
Image Analyst
el 5 de Jul. de 2020
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 comentarios
Image Analyst
el 6 de Jul. de 2020
Editada: Image Analyst
el 6 de Jul. de 2020
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;
Image Analyst
el 5 de Jul. de 2020
Try
plot(subplot1, t, ea, 'r-', 'LineWidth', 2)
grid on;
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!