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!
0 个评论
回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!