MATLAB: Warning: Rank deficient, rank = 2, tol = 7.141946e-13
ranktol
Hi,
Kindly, can someone assist to figure out what mistake i made on the attached code that is generating the error below?
'Warning: Rank deficient, rank = 2, tol =
7.141946e-13'
Thanks in advance
Best Answer
Your function needed a lot of cleanup, and I had to guess about what was desired so you should review it.
With the current code, when you run, at time 0 you will hit a breakpoint in calculating dSno3dt at n = 94, at the new temp2 partial calculation (the lines were too long to debug... copying and pasting is messy in the editor when it exceeds your screen width.)
The reason for the breakpoint is that the calculation will overflow to -infinity . That -infinity will then mix with other calculations leading to an attempt to calculate infinity - infinity which gives nan. Therefore the later fval all return as NaN, leading to an integration failure at time 0.
Please have a careful look at the changes I made. I had to index a number of arrays, and you need to review whether I indexed properly for your calculation purposes. You should also double-check that I got the sign right on adding / subtracting the sub-expressions.
When you work on the code, I recommend that you break the remaining code even further into sub-expressions, to make it easier to debug. Chasing down which operator is causing a problem in a long line of operations is a pain.
By the way:
%% conditions
if le (t,46)
Your functions are discontinuous in time. That is not permitted for the ode* solvers: the mathematics of the Runge-Kutta solvers is only valid for continuous functions. You must terminate the ode15s call at each one of those time boundaries and re-start integration.
Best Answer