Plot a second order equation and plot two equations on the same grafic

조회 수: 5 (최근 30일)
Igor
Igor 2012년 2월 8일
편집: Paul 2013년 10월 8일
Hi everyone,
1. I can't plot this function in a grafic, I think the code in the editor is not right. The second order equation is:
(a) dx^2/dt^2 (t) = -xg0*w0^2*sin(wf*t)-w0^2*x-2*M*w0*beta*dx/dt
xg0, w0, M, beta are constants.
2. Plot two solutions in the same grafic.
I already solve other system with ode45, now i want to plot that second order equation with one solution of this sistem.
It is a enginneering problem that consist in a structure with and without a vibration control system. One equation (a) give me the response without that control and the system of equations give me the response with that control... I need to compare that in the same grafic.
Thank's everyone.

채택된 답변

Kevin Holst
Kevin Holst 2012년 2월 8일
You can plot multiple sets of data on one figure multiple ways. The first way would be:
plot(x1,y1,x2,y2,...)
The next most common would involve using hold:
plot(x1,y1)
hold on
plot(x2,y2)
  댓글 수: 11
Kevin Holst
Kevin Holst 2012년 2월 8일
Also, don't forget to click accept answer under my name up there.
Igor
Igor 2012년 2월 10일
I have some other problem with my dissertation, sorry stop answering. I am a finalist of civil engineering.
All you say it works, thank's to you I have the program correct. Thank you.
I have another question. Now I have two functions in the same graphic. I need to calculate each maximum to calculate the effectiveness of the control system. What is the code for each function?
I send to a reduce EDITOR:
M=0.577;
mv=1000;
A=1.157*10^-5;
xg0=0.05;
w0=5.17;
wf=5.17;
beta=2/100;
alfa=0.7;
L=0.734;
g=9.81;
delta=0.5;
%Equation 1
r=@(t,y) [y(3); y(4); -xg0*w0^2*sin(wf*t)-w0^2*y(1)-2*w0*beta*y(3); 0];
[Tr,Yr]= ode45(r,[0 50],[0 0 0 0]);
%System of equations
s=@(t,y) [y(3); y(4); (-(M+mv*A*L)*xg0*w0^2*sin(wf*t)-M*w0^2*y(1)-2*M*w0*beta*y(3)-mv*A*alfa*L*((mv*A*alfa*L*((M+mv*A*L)*xg0*w0^2*sin(wf*t)+M*w0^2*y(1)+2*M*w0*beta*y(3))+(M+mv*A*L)*(-mv*A*alfa*L*xg0*w0^2*sin(wf*t)-2*mv*A*g*y(2)-(1/2)*mv*A*delta*abs(y(4))*y(4)))/(mv*A*L*(M+mv*A*L)-(mv*A*L)^2)))/(M+mv*A*L);(mv*A*alfa*L*((M+mv*A*L)*xg0*w0^2*sin(wf*t)+M*w0^2*y(1)+2*M*w0*beta*y(3))+(M+mv*A*L)*(-mv*A*alfa*L*xg0*w0^2*sin(wf*t)-2*mv*A*g*y(2)-(1/2)*mv*A*delta*abs(y(4))*y(4)))/(mv*A*L*(M+mv*A*L)-(mv*A*L)^2)];
[Ts,Ys]= ode45(s,[0 50],[0 0 0 0]);
%Graphic
plot(Ts,Ys(:,1),Tr,Yr(:,1))
% Effectiveness of the system ????
Tank's.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by