Plot each image on the same figure. Use enough time increments so that the period of the largest frequency of oscillation has about 40 time increments per period

1 次查看(过去 30 天)
I have equations for y1(t) and y2(t) that i found from a two mass two spring system. I have solved these equations for 6 different sets of initial conditions, so now i have 6 equations for y1(t) and 6 equations for y2(t). I am extremely new to matlab, so I do not even know where to begin.
For each of the 6 sets of equations, i need to plot y1(t) and y2(t) on the same figure for efficient comparison.
I must use enough time increments so that the period of the largest frequency of oscillation has about 40 time increments per period and i must use a final time that is three times the smallest period.

回答(2 个)

Ameer Hamza
Ameer Hamza 2020-6-1
You can do something like this
t = 0:0.001:10;
y11 = 0.2763*cos(1.59*t) + 0.7237*cos(3.39t);
y12 = % 1st equation for y2
y21 = % 2nd equation for y1
y22 = % 2nd equation for y2
y31
..
..
and the plot like this
hold on % do draw all lines on same figure
plot(t, y11);
plot(t, y12);
plot(t, y21);
..
..
  6 个评论
Image Analyst
Image Analyst 2020-6-2
If you have enough points in there, like more than a thousand or so, then the usual cause is the renderer. What does this say
>> opengl info
You could try turning on or off "software" or change renderers. But I'm no opengl expert so you might just call the Mathworks tech support, or search this forum for renderer.

请先登录,再进行评论。


Image Analyst
Image Analyst 2020-6-1
编辑:Image Analyst 2020-6-1
For the same figure, different axes, use subplot
subplot(2, 3, 1);
plot(t, y1);
subplot(2, 3, 2);
plot(t, y2);
subplot(2, 3, 3);
plot(t, y3);
subplot(2, 3, 4);
plot(t, y4);
subplot(2, 3, 5);
plot(t, y5);
subplot(2, 3, 6);
plot(t, y6);
For the same axes, use hold on:
plot(t, y1);
hold on;
plot(t, y2);
plot(t, y3);
plot(t, y4);
plot(t, y5);
plot(t, y6);
To find the period, realize that the number 1.59 or 3.39 is 2*pi/period. So
period1 = 2 * pi / 3.39
period2 = 2 * pi / 1.59
shortestPeriod = min([period1, period2]);
finalTime = 3 * shortestPeriod;
numSamples = % I'm sure you can figure this out.
t = linspace(0, finalTime, numSamples);

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by