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
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/307295/image.jpeg)
0 comentarios
Respuestas (2)
Ameer Hamza
el 1 de Jun. de 2020
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 comentarios
Image Analyst
el 2 de Jun. de 2020
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
el 3 de Jun. de 2020
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
el 1 de Jun. de 2020
Editada: Image Analyst
el 1 de Jun. de 2020
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 comentarios
Ver también
Categorías
Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!