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

2 views (last 30 days)
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.

Accepted Answer

Kevin Holst
Kevin Holst on 8 Feb 2012
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 Comments
Igor
Igor on 10 Feb 2012
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!