I need to obtain second derivative from a 2nd order ode

11 views (last 30 days)
Hi, I solved following 2 coupled 2nd order odes:
m*x"+c1*x'+k1*x=F1
m*y"+c2*y'+k2*y=F2
I used ode45 and obtained x,x',y and y'.
I need to obtain x" too. Can anyone please tell me how can I do so?

Accepted Answer

Friedrich
Friedrich on 5 Aug 2011
So, after rethinking the whole problem it looks that you are doing it 100% right.
You split up the 2nd order ODE into a coupled system of 1st order ODEs. After solving this system you get x, x’, y and y’. Now you want x’’ and y’’. This can be obtained from x’,x,y and y’ since you have a representation of x’’and y’’ through x,x’,y and y’. So this 2nd order ODE gives
m*x"+c1*x'+k1*x=F1
x‘‘ = (F1-ci*x‘-k1*x)/m
Since you know x and x‘ you can get x‘‘.
  2 Comments
Shantanu Chhaparia
Shantanu Chhaparia on 16 May 2022
What if the second order derivative is a function of some other second order derivatives. I basically have a 14 dof second order system I want to obtain all the 14 second order derivatives but they are function of other 2nd order dof. So how to go about that?
Torsten
Torsten on 16 May 2022
Edited: Torsten on 16 May 2022
Solve your system for the 2nd order derivatives of the variables.
Usually, the system can be written as
M(t,y,y') * y'' = f(t,y,y')
with a matrix M and a vector f both depending only on t,y, and y'
Then
y'' = M\f

Sign in to comment.

More Answers (2)

Friedrich
Friedrich on 5 Aug 2011
Hi,
Matlab can solve ODE of first order only. You have to convert your 2nd order ODE to a sytem of coupled 1st order ODE’s. How this is done can be obtained here:
  1 Comment
Arti
Arti on 5 Aug 2011
Thanks.
I reduced them to first order as:
dz(1)= z(2);
dz(2)=(F1-c1*z(2)-k1*z(1))/m;
dz(3)= z(4);
dz(4)=(F2-c2*z(4)-k2*z(3))/m;
So, z(:,1)=x, z(:,2)=x' , z(:,3)=y , z(:,4)=y'
Now if I want to obtain x", can MATLAB do it?

Sign in to comment.


Friedrich
Friedrich on 5 Aug 2011
I would suggest reading this article:
Your code should look similar to this:
function example
x_0 = [2,2];
tspan = [0,20];
[t,x] = ode45(@my_func,tspan,x_0);
plot(t,x);
function xbar = my_func( t,x )
F_1 = 10;
c_1 = 2;
k_1 = 1;
m = 5;
xbar = [x(2); (F_1 - c_1*x(2) - k_1*x(1))/m];
end
end
Where x(1) is x’ and x(2) is x’’.
  1 Comment
Arti
Arti on 5 Aug 2011
Thanks!!
But c1 shd be multiplied with x' and k1 with x. I need all three of them, x, x' and x".
here is my code:
function dz=znew(t,z)
m=7.5;
c_x=1880;
c_y=2160;
k_x=27300;
k_y=30200;
F_0x=460;
F_0y=350;
w=2;
dz=zeros(size(z));
dz(1)=z(2);
dz(2)=(sin(w*t)*F_0x-c_x*z(2)-k_x*z(1))/m;
dz(3)=z(4);
dz(4)=(sin(w*t)*F_0y-c_y*z(4)-k_y*z(3))/m;
clear all
close all
echo on
z0=[0 0 0 0];
[t,z]=ode45(@znew2,[0 10],z0);
plot(t,z(:,1));
title ('t vs x');
xlabel ('time (sec)');
ylabel ('tool displacement x (m)')
grid on;
echo off

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!