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!