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.
0 个评论
回答(2 个)
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
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.
Ameer Hamza
2020-6-3
For the issue related to plotting y2(t)/y1(t), you need to use element-wise operator
plot(t, y12./y11);
plot(t, y22./y21);
..
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);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!