Producing Matrix with zero determinant with ode45
Show older comments
I have a ode solver that uses ode45 to solve an ode with an intial state that consists of 18 variables. When I use a specific combination of initial values, I somehow produce a Euler rotation matrix that has a zero determinant which breaks the solver as I later use that matrix to solve a system of equations ie I have a line that does something like
vector1 = euler\vector2
The euler rotation matrix is computed like this
Rocket.EulerRotMat = [
1 0 -sind(ElevAngle);
0 cosd(RollAngle) cosd(ElevAngle)*sind(RollAngle);
0 -sind(RollAngle) cosd(ElevAngle)*cosd(RollAngle)];
So what I do is view the variable and copy all the 16 digits of each of the 18 initial conditions and plug that into the solver. When I do it this way, it seems I don't produce a zero determinant. What is somewhat interesting is that the difference between the copied value and the actual value that MATLAB plugs in has a difference of 10^-16. What is also interesting is that for the two different runs (one that worked and one that broke), all the position values and velocity values (x,y,z) plus those relating to pitch that the solver computed are basically the same (mind some tiny differences in decimal places) except for those that pertain to the roll and yaw (makes sense as the euler rotation matrix doesn't work). For example, this graph shows roll velocity vs time where the blue line came from me manually copying the 16 digits of each value into the solver and the orange line came from MATLAB's internal value which broke the solver, hence the line is shorter. What somewhat makes no sense to me is how that a difference of 10^-16 for each of the 18 variables can cause it to diverge so much.

2 Comments
David Goodmanson
on 4 Feb 2021
Hello WS,
That does not look like a good rotation matrix at all. It's supposed to be an orthonormal matrix, but if you take the dot product of, say, column 1 and column 3 you don't get zero.
Wei Yang Shen
on 4 Feb 2021
Answers (0)
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!