Error using sym/cat>checkDimensions (line 70) CAT arguments dimensions not consistent.

Hi everyone, On running the code on the attachment/or dropbox link
https://www.dropbox.com/s/l5f3096vinkxmuc/ODE15iExample.m?dl=0
I get the error message:
Error using sym/cat>checkDimensions (line 70)
CAT arguments dimensions not consistent.
Error in sym/cat>catMany (line 35)
[resz, ranges] = checkDimensions(sz,dim);
Error in sym/cat (line 27)
ySym = catMany(dim, args);
Error in sym/vertcat (line 19)
ySym = cat(1,args{:});
Error in ODE15iExample (line 8)
eqs = [diff(c(t),t) == 1 / 1.5e-6 * (1.666667e-5 * 6.51332e-2 - 1.666667e-5 * c(t)) - ((c(t) * 8.314 * 323.15 - 149 * b(t)) / (1 /
4.14e-6) + (149 / ((1 + (1.39e-9 * d(t)) / (2.89e-9 * e(t))) * 8.4e-4)))...
What can I do?

 Accepted Answer

I did not troubleshoot all the errors that might be in your code, only the ones in the ‘eqs’ vector. Spaces are important, and please do not use continuation ellipses when you intend a new line. Rather than manually remove the spaces, I just put every line in parentheses. Note that the continuation line in the ‘diff(v(t),t) ==’ line, there is a missing operator. I used a + creating ‘+ n(t)’, so if I guessed wrong, replace it appropriately.
Try this version of ‘eqs’:
eqs = [(diff(c(t),t) == 1 / 1.5e-6 * (1.666667e-5 * 6.51332e-2 - 1.666667e-5 * c(t)) - ((c(t) * 8.314 * 323.15 - 149 * b(t)) / (1 / 4.14e-6) + (149 / ((1 + (1.39e-9 * d(t)) / (2.89e-9 * e(t))) * 8.4e-4))) );
(diff(g(t),t) == 1/1.5e-6 * (-1.666667e-5 * g(t)) -( 9.598e-4 * ( 1 + (1.39e-9 * d(t)) /( 3.53e-9 * h(t))) * (g(t) * 8.314 * 323.15 / 5.15e3 - i(t))) );
(diff(e(t),t) == ((c(t) * 8.314 * 323.15 - 149 * b(t)) / (1 / 4.14e-6) + ( 149 / ((1 + (1.39e-9 * d(t)) / ( 2.89e-9 * e(t))) * 8.4e-4)) - (0.162 * exp(5153/323.15) * (((d(t) * k(t)) / 1.07e-7) - 1) * (10 / ((d(t) * k(t)) / 1.07e-7)))) );
(diff(h(t),t) == (9.598e-4 * ( 1 + (1.39e-9 * d(t)) / (3.53e-9 * h(t))) * (g(t) * 8.314 * 323.15 / 5.15e3 - i(t))) - (-8.825e-3 * 12.54 * 100.0869 * m(t) * n(t) * (1-(0.84*n(t)) / (1 + 0.84 * n(t)))) );
(diff(u(t),t) == (-8.825e-3 * 12.54 * 100.0869 * m(t) * n(t) * (1 - (0.84 * n(t)) /(1 + 0.84 * n(t)))) - (0.162 * exp(-5153/323.15) * (((d(t) * k(t)) / 1.07e-7) - 1 * (10 /((d(t) * k(t)) / 1.07e-7)))) );
(diff(m(t),t) == -m(t) * (-8.825e-3 * 12.54 * 100.0869 * m(t) * n(t) * ( 1 - (0.84 * n(t)) / (1 + 0.84 * n(t)))) * 100.0869 / 2703 );
(diff(v(t),t) == (-8.825e-3 * 12.54 * 100.0869 * m(t) * n(t) * (1 - (0.84 * n(t)) / (1 + 0.84 * n(t)))) * 258.30 / 2540 ...
+ n(t) + 2 * d(t) - ((e(t) * 6.24 * n(t)) / (n(t)^2 + 6.24 * n(t) + 6.24 * 5.68e-5)) - 2 * ((e(t) * 6.24 * 5.68e-5) / (n(t)^2 + 6.24 * n(t) + 6.24 * 5.68e-5)) - ((h(t) * 1.7e-3 *n(t)) / (n(t)^2 + 1.7e-3 * n(t) + 1.7e-3 * 6.55e-8)) - 2 * ((h(t) * 1.7e-3 * 6.55e-8) / (n(t)^2 + 1.7e-3 * n(t) + 1.7e-3 * 6.55e-8)) - 5.3e-8 / n(t) == 0) ;
(1.7e-3 == n(t) * r(t) / i(t) );
(6.55e-8 == n(t) * s(t) / r(t) );
(6.24 == n(t) * q(t) / b(t) );
(5.68e-5 == n(t) * k(t) / q(t) );
(5.3e-8 == n(t) * tt(t) );
(e(t) == b(t) + q(t) + k(t) );
(h(t) == i(t) + r(t) + s(t) );
(u(t) == i(t) + r(t) + s(t))];
If you want ‘eqs’ to be a row vector instead of a column vector, replace the semicolons at the end of each line with commas.

6 Comments

Thanks a lot, it worked. My current error is:
"Error using sym/isLowIndexDAE (line 46) Expecting as many equations as variables.
Error in ODE15iExample (line 44) isLowIndexDAE(eqs, vars); >>"
As always, my pleasure.
When I looked at your variables and my ‘eqs’ vector just now, I counted 15 equations and 16 variables.
I defer to you to solve that. The symvar (link) function may facilitate it. (I haven’t used it with ‘eqs’.)
I have solved that, there is 16 equations with 16 variables, and the new error is:
">> ODE15iExample Matrix dimensions must agree.
Error in odenumjac (line 103) yscale = max(abs(y),thresh);
Error in ode15ipdupdate (line 29) [dfdyp,dfdyp_options.fac,NF] = odenumjac(odefun,{t,y,yp,extras{:}},f,dfdyp_options);
Error in ode15ipdinit (line 76) ode15ipdupdate([],odefun,t0,y0,yp0,f0,dfdy,dfdyp,dfdy_options,dfdyp_options,extras);
Error in decic (line 70) ode15ipdinit(odefun,t0,y0,yp0,res,options,varargin);
Error in ODE15iExample (line 70) [y0,yp0] = decic(f, t0, [1;0;1;0;1;1e-12;1;7.413e-12;1.349e-9;1e-12;4.996e-2;1;1;1;1;1;1;1], [], zeros(16,1), [], opt);
>> "
I have no idea how to troubleshoot that.
I have no idea what it even refers to.
I'll try to figure it out. Thanks a lot for all the help you provided. I truly appreciate.
My pleasure, as always.
I have no recent experience with DAE functions, so troubleshooting code using them requires that the errors involve something I’m familiar with.

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!