The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to get second derivatives using ode45
Replies: 4   Last Post: Apr 30, 2013 11:15 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
stanley ontario

Posts: 3
Registered: 4/30/13
Re: How to get second derivatives using ode45
Posted: Apr 30, 2013 11:15 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

> For i=1:numel(t_vec)
> y(1)=Y(i,1);
> y(2)=Y(i,2);
> y(3)=Y(i,3);
> y(4)=Y(i,4);
> t=t_vec(i);
> dy=vib_equ(t,y,c_s_f,c_s_r,v_val,F_d_val,m_c,I_g_c,l,l_f,l_r,u_f,u_f_dot,v,L,i_d);
> Y_acc(i,1) = dy(2);
> Y_acc(i,2) = dy(4);
> end
> does not work ?
> (Of course you will have to supply the correct values for the variables in your calling list to vib_equ)
> Or use the OutputFcn facility during the computation with ode45.
> Best wishes
> Torsten.

Thank you again for your answer!

I understand your code, however I have a matrix dimension error now.
Here's what it looks like inside the function:
function dy = vib_equ(t,y,c_s_f,c_s_r,v_val,F_d_val,m_c,I_g_c,l,l_f,l_r,u_f,u_f_dot,v,L,i_d);


v_d_f= (z_cf_dot-u_f_dot(t,L,v))/i_d;
v_d_r= (z_cr_dot-u_f_dot(t-l/v,L,v))/i_d;

F_dw_f= interp1(v_val,F_d_val,v_d_f,'spline');
F_dw_r= interp1(v_val,F_d_val,v_d_r,'spline');


MC= [m_c 0; 0 m_c];
A= [-K1*c_s_f 0 -K2*c_s_r 0; -K4*c_s_f 0 -K3*c_s_r 0];
B= [-K1/i_d*F_dw_f+K1*c_s_f*u_f(t,L,v)-K2/i_d*F_dw_r+K2*c_s_r*u_f((t-l/v),L,v); -K3/i_d*F_dw_r+K3*c_s_r*u_f((t-l/v),L,v)-K4/i_d*F_dw_f+K4*c_s_f*u_f(t,L,v)];
C= inv(MC)*A;
D= inv(MC)*B;


dy= zeros(4,1);
dy(1)= y(2);
dy(2)= z_ddot(1);
dy(3)= y(4);
dy(4)= z_ddot(2);

And I have an error at z_ddot=C*y+D because of the matrix dimensions now.

I really don't understand why.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.