Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
ode23 not converging

Subject: ode23 not converging

From: Windell

Date: 19 Nov, 2009 06:23:02

Message: 1 of 1

Hi,

I have written a short MATLAB program that calculates the kinematics and dynamics of a satellite with a feedback control loop. The equations I know for sure are correct as they were given to me to simulate the motion of the satellite. However, when I use ode23 to solve them, MATLAB runs and runs without the ode23 converging. Any suggestions to see where I could have gone wrong? Here is my code.

%define some initial conditions.
%orbital insertion tumbling angular velocity.
Omega_BI=0.5*rand(1,3);
%initial orientation of the satellite's antenna vector in the LVLH frame.
Gamma=[0 1 0];
%set to analyze the model for 100s.
t0=0;tf=1;
%solve differtial eqns.
[t,z]=ode23('diffeqs2',[t0 tf],[Omega_BI Gamma]);

function q=diff_eqs(t,x)
%define needed unit vectors.
e1=[1 0 0]';
e3=[0 0 1]';
%create skew symmetric matrix of e3 unit vector.
e3cross=[0 -1 0;1 0 0;0 0 0];
%satellite intertial matrix. (kg-m^2)
J=eye(3,3)*6.667*10^-3;
%satellite orbital angular velocity (rad/s)
Omega_L=1.1636*10^-3;
%define initial orientation of satellite in orbit wrt
%intertial coordinate frame
R_0=eye(3,3);
%define a positive scalar kp.
k_p=5;

%assign the inputs.
Omega_BI=[x(1) x(2) x(3)]';
Gamma=[x(4) x(5) x(6)]';

%define the diff equations.
R_LI=R_0*exp(Omega_L*e3cross*t);
Omega=R_LI*(Omega_BI-Omega_L*e3);
u=-k_p*R_LI'*(cross(Gamma,e1)+Omega)-Omega_L*(cross(J*Omega_BI,e3));
dotOmega_BI= inv(J)*(cross(J*Omega_BI,Omega_BI)+ u);
dotGamma=cross(Gamma,R_LI*(Omega_BI-Omega_L*e3));
q=[dotOmega_BI; dotGamma];

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us