Solving a second order differential equations with multi variables using "MASS" function in odeset by ODE45

조회 수: 3 (최근 30일)
Hello to anyone who's reading this!
I'm trying to solve a set of second order differential equations using ode45, but when I change my ICs a little bit I get this error "Warning: Matrix is close to singular or badly scaled. Results may be inaccurate" . obviously my Mass matrix is not usable by MATLAB. I'd like to know how can I fix this ? I'd rather stay using ode45 if possible.
function [ m ] = Mass( t,q )
M0 = 2; M1 = 1; M2 = 1;
g = 1;
l1= 1; l2 = 1;
m1 = [ 1 0 0 0 0 0 ];
m2 = [ 0 (M0+M1+M2) 0 -M1*l1*cosd(q(3)) 0 -M2*l2*cosd(q(5)) ];
m3 = [ 0 0 1 0 0 0 ];
m4 = [ 0 -M1*l1*cosd(q(3)) 0 M1*(l1.^2) 0 0 ];
m5 = [ 0 0 0 0 1 0];
m6 = [ 0 -M2*l2*cosd(q(5)) 0 0 0 M2*(l2.^2) ];
m = [m1;m2;m3;m4;m5;m6];
end
clear all;close all;clc;
tspan = [0 40];
q0 = [ 0 0 -90.01 0 90 0 ];
options = odeset('MASS',@Mass);
[t,q] =ode45(@State_F,tspan,q0,options);
So this happens when q0(3) ~ -90 and q0(5) ~ 90. It perfectly works when They're around smaller numbers such as 10-20-25. I have checked the mathematics couple of times. If you still believe something is wrong with the mathematics as well please let me know. I really appreciate you taking the time!

답변 (2개)

Ebraheem Menda
Ebraheem Menda 2018년 1월 3일
To answer this you must tell what is State_F.

Ebraheem Menda
Ebraheem Menda 2018년 1월 3일
One more thing is you did not give the 2nd order diff. equation.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by