vertical dimensions mismatch ode45

10 views (last 30 days)
I'm trying to solve a system of ODE with 43 equations and 156 constants ,here is my code:
clear all,clc
%temperature
T=17000
%constante k:
k1=2.36 *(1e-12)*(T/300)^(-0.29)*exp(17.60/T)
k2 =3.24 *(1e-12) *(T/300)^(-0.66)
k3=3.50 *(1e-12)*(T/300)^(-0.53)* exp(3.20/T)
..
k156=...
%initial conditions
[IC1,IC2,IC3,IC4,IC5,IC6,IC7,IC8,IC9,IC10...,IC43]=deal(10^19)
IC=[IC1 IC2 IC3 IC4 IC5 IC6 IC7 IC8 IC9 IC10 IC11 ..... IC43]
%time
t0 = 0;
tf = 1E-7;
t1 = 5E-12;
f= @(t,n) [k1*n(2)*n(42)+k15*n(5)*n(9)+k16*n(5)*n(26)+k25*n(4)*n(26)+k29*n(4)*n(9)+k33*n(4)*n(11)+...
.. ]
%resolving
[t,n]= ode45(f,[0 5E-12 1E-7], IC )
plot(t,n)
error: vertical dimensions mismatch (13x1 vs 1x2)
error: called from
conc>@<anonymous> at line 246 column 506
starting_stepsize at line 53 column 5
ode45 at line 196 column 25
conc at line 247 column 6
  16 Comments
Imene Yed
Imene Yed on 22 May 2021
thnk you so much I will try it then I will tell you if it works ,anyway thank you for all your answers.

Sign in to comment.

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 22 May 2021
Hi,
While defining your fcn handle, you have omitted several empty spaces that created additonal elements in your fcn handle (f). Now all errs are removed and it is works. Your system response is very unstable. You need to take care of your initial conditions. Here is the corrected fcn handle:
...
IC = 1e19*ones(1,43); % Test: IC = 1e9*ones(1,43)
%%
F=@(t,n)([k1*n(2)*n(42)+k15*n(5)*n(9)+k16*n(5)*n(26)+k25*n(4)*n(26)+k29*n(4)*n(9)+k33*n(4)*n(11)+k39*n(7)*n(26)+k40*n(7)*n(27)+k43*n(7)*n(9)+k44*n(7)*n(12)+k48*n(9)*n(9)+k59*n(11)*n(42)+k72*n(2)*n(24)+k104*n(3)*n(5)+k105*n(3)*n(8)+k106*n(3)*n(25)+k117*n(18)*n(2)+k119*n(3)*n(43)+k122*n(11)*n(43)+k124*n(13)*n(43)+k130*n(22)*n(43)-k4*n(1)*n(37)-k8*n(1)*n(15)-k9*n(1)*n(26)-k10*n(1)*n(24)-k11*n(1)*n(20)-k12*n(1)*n(35)-k13*n(1)*n(22)-k61*n(2)*n(1)-k64*n(1)*n(13)-k65*n(1)*n(4)-k66*n(1)*n(9)-k67*n(1)*n(5)-k68*n(1)*n(1)-k69*n(1)*n(7)-k73*n(1)*n(27)-k74*n(1)*n(11)-k75*n(1)*n(23)-k76*n(1)*n(21)-k77*n(1)*n(19)-k118*n(1)*n(43)-k132*n(1)*n(42)-k136*n(1)*n(3)-k137*n(1)*n(12)-k138*n(1)*n(14)-k139*n(1)*n(6)-2*k164*n(7)*n(1)*n(1)+k164*n(7)*n(1)^(2)-k163*n(1)*n(15)*n(4)+k163*n(1)*n(15)*n(4)-k165*n(1)*n(32)*n(4)+k165*n(1)*n(32)*n(4);
-k1*n(2)*n(42)-k5*n(2)*n(15)-k6*n(2)*n(30)-k7*n(2)*n(36)-k61*n(2)*n(1)-k62*n(2)*n(7)-k63*n(2)*n(4)-k72*n(2)*n(24)-k117*n(18)*n(2)+k45*n(7)*n(11)+k73*n(1)*n(27)+k74*n(1)*n(11)+k75*n(1)*n(23)+k76*n(1)*n(21)+k77*n(1)*n(19)+k118*n(1)*n(43)+k122*n(11)*n(43);
k32*n(4)*n(12)+k132*n(1)*n(42)-k14*n(3)*n(24)-k104*n(3)*n(5)-k105*n(3)*n(8)-k106*n(3)*n(25)-k119*n(3)*n(43)-k136*n(1)*n(3)-k140*n(3)*n(4)-k141*n(3)*n(15)-k142*n(3)*n(7);
k2*n(5)*n(42)+k8*n(1)*n(15)+k10*n(1)*n(24)+k13*n(1)*n(22)+k14*n(3)*n(24)+k35*n(7)*n(15)+k36*n(7)*n(19)+k37*n(7)*n(24)+k38*n(7)*n(32)+k52*n(15)*n(24)+k53*n(15)*n(20)+k55*n(15)*n(22)+k56*n(15)*n(26)+k78*n(5)*n(9)+k79*n(5)*n(22)+k80*n(5)*n(30)+k81*n(5)*n(15)+k84*n(6)*n(15)+k85*n(6)*n(26)+k104*n(3)*n(5)+2*k107*n(5)*n(6)+k108*n(5)*n(18)+k109*n(6)*n(8)+k120*n(6)*n(43)+2*k126*n(15)*n(43)+k128*n(19)*n(43)+k130*n(22)*n(43)+k131*n(24)*n(43)+k162*n(42)*n(4)*n(15)-k19*n(4)*n(24)-k20*n(4)*n(32)-k21*n(4)*n(30)-k22*n(4)*n(30)-k23*n(4)*n(20)-k24*n(4)*n(36)-k25*n(4)*n(26)-k26*n(4)*n(26)-k27*n(4)*n(13)-k28*n(4)*n(35)-k29*n(4)*n(9)-k30*n(4)*n(21)-k31*n(4)*n(14)-k32*n(4)*n(12)-k33*n(4)*n(11)-k63*n(2)*n(4)-k65*n(1)*n(4)-2*k70*n(4)*n(4)-k82*n(4)*n(21)-k83*n(4)*n(23)-k133*n(4)*n(42)-k140*n(3)*n(4)-k143*n(4)*n(6)-k144*n(4)*n(12)-k161*n(42)*n(4)*n(15)-k162*n(42)*n(4)*n(15)-k163*n(1)*n(15)*n(4)-k165*n(1)*n(32)*n(4);
k5*n(2)*n(15)+k34*n(8)*n(15)+k82*n(4)*n(21)+k83*n(4)*n(23)+k128*n(19)*n(43)-k19*n(4)*n(24)-k20*n(4)*n(32)-k21*n(4)*n(30)-k22*n(4)*n(30)-k23*n(4)*n(20)-k24*n(4)*n(36)-k25*n(4)*n(26)-k26*n(4)*n(26)-k27*n(4)*n(13)-k28*n(4)*n(35)-k29*n(4)*n(9)-k30*n(4)*n(21)-k31*n(4)*n(14)-k32*n(4)*n(12)-k33*n(4)*n(11)-k63*n(2)*n(4)-k65*n(1)*n(4)-2*k70*n(4)*n(4)-k82*n(4)*n(21)-k83*n(4)*n(23)-k133*n(4)*n(42)-k140*n(3)*n(4)-k143*n(4)*n(6)-k144*n(4)*n(12)-k161*n(42)*n(4)*n(15)-k162*n(42)*n(4)*n(15)-k163*n(1)*n(15)*n(4)-k165*n(1)*n(32)*n(4);
k133*n(4)*n(42)+k161*n(42)*n(4)*n(15)-k84*n(6)*n(15)-k85*n(6)*n(26)-k107*n(5)*n(6)-k109*n(6)*n(8)-k120*n(6)*n(43)-k139*n(1)*n(6)-k143*n(4)*n(6)-k145*n(6)*n(24)-k146*n(6)*n(22)-k147*n(6)*n(7);
k3*n(8)*n(42)+k9*n(1)*n(26)+k11*n(1)*n(20)+k18*n(5)*n(20)+k19*n(4)*n(24)+k23*n(4)*n(20)+k26*n(4)*n(26)+k30*n(4)*n(21)+2*k60*n(21)*n(42)+k86*n(8)*n(15)+k87*n(8)*n(9)+k88*n(8)*n(22)+k89*n(8)*n(26)+k90*n(8)*n(24)+k105*n(3)*n(8)+k109*n(6)*n(8)+k110*n(8)*n(18)+k111*n(8)*n(12)+k112*n(8)*n(28)+k113*n(8)*n(14)+2*k129*n(20)*n(43)+k131*n(24)*n(43)+2*k159*n(20)*n(42)-k35*n(7)*n(15)-k36*n(7)*n(19)-k37*n(7)*n(24)-k38*n(7)*n(32)-k39*n(7)*n(26)-k40*n(7)*n(27)-k41*n(7)*n(13)-k42*n(7)*n(14)-k43*n(7)*n(9)-k44*n(7)*n(12)-k45*n(7)*n(11)-k46*n(7)*n(35)-k62*n(2)*n(7)-k69*n(1)*n(7)-k71*n(8)*n(7)-k91*n(7)*n(21)-k142*n(3)*n(7)-k147*n(6)*n(7)-k164*n(7)*n(1)*n(1);
k91*n(7)*n(21)-k3*n(8)*n(42)-k34*n(8)*n(15)-k71*n(8)*n(7)-k86*n(8)*n(15)-k87*n(8)*n(9)-k88*n(8)*n(22)-k89*n(8)*n(26)-k90*n(8)*n(24)-k105*n(3)*n(8)-k109*n(6)*n(8)-k110*n(8)*n(18)-k111*n(8)*n(12)-k112*n(8)*n(28)-k113*n(8)*n(14);
k9*n(1)*n(26)+k12*n(1)*n(35)+k13*n(1)*n(22)+k27*n(4)*n(13)+k41*n(7)*n(13)+k68*n(1)*n(1)+k74*n(1)*n(11)+k94*n(11)*n(24)+k111*n(8)*n(12)+k115*n(12)*n(25)+k121*n(9)*n(43)+k123*n(12)*n(43)+k124*n(13)*n(43)+k136*n(1)*n(3)+k153*n(10)*n(42)+k154*n(10)^(2)+k155*n(10)*n(1)-k15*n(5)*n(9)-k29*n(4)*n(9)-k43*n(7)*n(9)-k47*n(9)*n(15)-2*k48*n(9)*n(9)-k49*n(9)*n(19)-k66*n(1)*n(9)-k78*n(5)*n(9)-k87*n(8)*n(9)-k92*n(9)*n(23)-k93*n(9)*n(27)-k121*n(9)*n(43)-k134*n(9)*n(42)-k148*n(9)*n(12)-k150*n(9)*n(42);
k150*n(9)*n(42)-k153*n(10)*n(42)-k154*n(10)^(2)-k155*n(10)*n(1);
k61*n(2)*n(1)+k78*n(5)*n(9)+k87*n(8)*n(9)+k92*n(9)*n(23)+k93*n(9)*n(27)-k33*n(4)*n(11)-k45*n(7)*n(11)-k50*n(11)*n(15)-k59*n(11)*n(42)-k74*n(1)*n(11)-k94*n(11)*n(24)-k122*n(11)*n(43);
-k32*n(4)*n(12)-k44*n(7)*n(12)-k111*n(8)*n(12)-k115*n(12)*n(25)-k123*n(12)*n(43)-k137*n(1)*n(12)-k144*n(4)*n(12)-k148*n(9)*n(12)-k149*n(12)*n(13)+k31*n(4)*n(14)+k42*n(7)*n(14)+k134*n(9)*n(42);
k48*n(9)*n(9)+k66*n(1)*n(9)+k113*n(8)*n(14)+k114*n(14)*n(25)+k125*n(14)*n(43)+k137*n(1)*n(12)-k27*n(4)*n(13)-k41*n(7)*n(13)-k64*n(1)*n(13)-k124*n(13)*n(43)-k135*n(13)*n(42)-k149*n(12)*n(13);
k135*n(13)*n(42)-k31*n(4)*n(14)-k42*n(7)*n(14)-k113*n(8)*n(14)-k114*n(14)*n(25)-k125*n(14)*n(43)-k138*n(1)*n(14);
k17*n(5)*n(32)+k19*n(4)*n(24)+k20*n(4)*n(32)+k21*n(4)*n(30)+k57*n(24)*n(24)+k70*n(4)*n(4)+k77*n(1)*n(19)+k97*n(19)*n(32)+k98*n(19)*n(24)+k108*n(5)*n(18)+k110*n(8)*n(18)+k116*n(18)*n(25)+k117*n(18)*n(2)+k127*n(18)*n(43)+k143*n(4)*n(6)+2*k156*n(18)*n(15)+2*k157*n(18)*n(16)+2*k158*n(18)*n(17)+k161*n(42)*n(4)*n(15)-k5*n(2)*n(15)-k8*n(1)*n(15)-k34*n(8)*n(15)-k35*n(7)*n(15)-k47*n(9)*n(15)-k50*n(11)*n(15)-k51*n(15)*n(37)-k52*n(15)*n(24)-k53*n(15)*n(20)-k54*n(15)*n(27)-k55*n(15)*n(22)-k56*n(15)*n(26)-k81*n(5)*n(15)-k84*n(6)*n(15)-k86*n(8)*n(15)-k95*n(15)*n(21)-k96*n(15)*n(23)-k126*n(15)*n(43)-k141*n(3)*n(15)-k151*n(15)*n(42)-k152*n(15)*n(42)-k156*n(18)*n(15)-k161*n(42)*n(4)*n(15)-k162*n(42)*n(4)*n(15)-k163*n(1)*n(15)*n(4);
k151*n(42)*n(15)-k157*n(16)*n(18);
k152*n(42)*n(15)-k158*n(17)*n(18);
k84*n(6)*n(15)+k162*n(42)*n(4)*n(15)-k108*n(5)*n(18)-k110*n(8)*n(18)-k116*n(18)*n(25)-k117*n(18)*n(2)-k127*n(18)*n(43)-k156*n(18)*n(15)-k157*n(18)*n(16)-k158*n(18)*n(17);
k81*n(5)*n(15)+k86*n(8)*n(15)+k95*n(15)*n(21)+k96*n(15)*n(23)-k36*n(7)*n(19)-k49*n(9)*n(19)-k77*n(1)*n(19)-k97*n(19)*n(32)-k98*n(19)*n(24)-k128*n(19)*n(43);
k21*n(4)*n(30)+k37*n(7)*n(24)+k39*n(7)*n(26)+k57*n(24)*n(24)+k76*n(1)*n(21)+k82*n(4)*n(21)+k91*n(7)*n(21)+k95*n(15)*n(21)+k99*n(21)*n(26)+k100*n(21)*n(22)-k11*n(1)*n(20)-k18*n(5)*n(20)-k23*n(4)*n(20)-k53*n(15)*n(20)-k129*n(20)*n(43)-k159*n(20)*n(42)-k160*n(20)*n(42);
k40*n(7)*n(27)+k71*n(8)*n(7)+k160*n(20)*n(42)-k30*n(4)*n(21)-k60*n(21)*n(42)-k76*n(1)*n(21)-k82*n(4)*n(21)-k91*n(7)*n(21)-k95*n(15)*n(21)-k99*n(21)*n(26)-k100*n(21)*n(22);
k4*n(1)*n(37)+k5*n(2)*n(15)+k8*n(1)*n(15)+k24*n(4)*n(36)+k26*n(4)*n(26)+k27*n(4)*n(13)+k28*n(4)*n(35)+k29*n(4)*n(9)+k31*n(4)*n(14)+k32*n(4)*n(12)+2*k47*n(9)*n(15)+k49*n(9)*n(19)+k50*n(11)*n(15)+k54*n(15)*n(27)+k58*n(24)*n(37)+k65*n(1)*n(4)+k75*n(1)*n(23)+k83*n(4)*n(23)+k92*n(9)*n(23)+k96*n(15)*n(23)+k102*n(24)*n(23)+k139*n(1)*n(6)+k140*n(3)*n(4)-k13*n(1)*n(22)-k55*n(15)*n(22)-k79*n(5)*n(22)-k88*n(8)*n(22)-k100*n(21)*n(22)-k101*n(22)*n(27)-k130*n(22)*n(43)-k146*n(6)*n(22);
k7*n(2)*n(36)+k15*n(5)*n(9)+k33*n(4)*n(11)+k49*n(9)*n(19)+k50*n(11)*n(15)+k63*n(2)*n(4)+k67*n(1)*n(5)+k79*n(5)*n(22)+k88*n(8)*n(22)+k100*n(21)*n(22)+k101*n(22)*n(27)-k75*n(1)*n(23)-k83*n(4)*n(23)-k92*n(9)*n(23)-k96*n(15)*n(23)-k102*n(24)*n(23);
k20*n(4)*n(32)+k22*2*n(4)*n(30)+k23*n(4)*n(20)+k24*n(4)*n(36)+k25*n(4)*n(26)+k34*n(8)*n(15)+k35*n(7)*n(15)+k51*n(15)*n(37)+k106*n(3)*n(25)+k114*n(14)*n(25)+k115*n(12)*n(25)+k116*n(18)*n(25)+k147*n(6)*n(7)-k10*n(1)*n(24)-k14*n(3)*n(24)-k19*n(4)*n(24)-k37*n(7)*n(24)-k52*n(15)*n(24)-k57*2*n(24)*n(24)-k58*n(24)*n(37)-k72*n(2)*n(24)-k90*n(8)*n(24)-k94*n(11)*n(24)-k98*n(19)*n(24)-k102*n(24)*n(23)-k103*n(24)*n(27)-k131*n(24)*n(43)-k145*n(6)*n(24);
k6*n(2)*n(30)+k16*n(5)*n(26)+k17*n(5)*n(32)+k18*n(5)*n(20)+k30*n(4)*n(21)+k36*n(7)*n(19)+k54*n(15)*n(27)+k72*n(2)*n(24)+k90*n(8)*n(24)+k94*n(11)*n(24)+k98*n(19)*n(24)+k102*n(24)*n(23)+k103*n(24)*n(27)-k106*n(3)*n(25)-k114*n(14)*n(25)-k115*n(12)*n(25)-k116*n(18)*n(25);
k4*n(1)*n(37)+k6*n(2)*n(30)+k7*n(2)*n(36)+k10*n(1)*n(24)+k11*n(1)*n(20)+k12*n(1)*n(35)+k28*n(4)*n(35)+k41*n(7)*n(13)+k42*n(7)*n(14)+k43*n(7)*n(9)+k45*n(7)*n(11)+k46*2*n(7)*n(35)+k69*n(1)*n(7)+k73*n(1)*n(27)+k93*n(9)*n(27)+k101*n(22)*n(27)+k103*n(24)*n(27)+k112*n(8)*n(28)+k142*n(3)*n(7)+k164*n(7)*n(1)*n(1)-k9*n(1)*n(26)-k16*n(5)*n(26)-k25*n(4)*n(26)-k26*n(4)*n(26)-k39*n(7)*n(26)-k56*n(15)*n(26)-k85*n(6)*n(26)-k89*n(8)*n(26)-k99*n(21)*n(26);
k62*n(2)*n(7)+k89*n(8)*n(26)+k99*n(21)*n(26)-k40*n(7)*n(27)-k54*n(15)*n(27)-k73*n(1)*n(27)-k93*n(9)*n(27)-k101*n(22)*n(27)-k103*n(24)*n(27);
k14*n(3)*n(24)+k44*n(7)*n(12)+k85*n(6)*n(26)-k112*n(8)*n(28);
k163*n(1)*n(15)*n(4);
k38*n(7)*n(32)+k53*n(15)*n(20)+k58*n(24)*n(37)-k6*n(2)*n(30)-k21*n(4)*n(30)-k22*n(4)*n(30)-k80*n(5)*n(30);
k80*n(5)*n(30);
k52*n(15)*n(24)+k145*n(6)*n(24)-k17*n(5)*n(32)-k20*n(4)*n(32)-k38*n(7)*n(32)-k97*n(19)*n(32)-k165*n(1)*n(32)*n(4);
k97*n(19)*n(32);
k51*n(15)*n(37)+k55*n(15)*n(22)+k141*n(3)*n(15)+k146*n(6)*n(22);
-k12*n(1)*n(35)-k28*n(4)*n(35)-k46*n(7)*n(35);
-k7*n(2)*n(36)-k24*n(4)*n(36);
-k4*n(1)*n(37)-k51*n(15)*n(37)-k58*n(24)*n(37)+k56*n(15)*n(26);
k165*n(1)*n(32)*n(4);
k144*n(4)*n(12);
k64*n(1)*n(13)+k138*n(1)*n(14)+k148*n(9)*n(12);
k149*n(12)*n(13);
k118*n(1)*n(43)+k119*n(3)*n(43)+k120*n(6)*n(43)+k121*n(12)*n(43)+k123*n(12)*n(43)+k125*n(14)*n(43)+k127*n(18)*n(43)+k136*n(1)*n(3)+k137*n(1)*n(12)+k138*n(1)*n(14)+k139*n(1)*n(6)+k140*n(3)*n(4)+k141*n(3)*n(15)+k142*n(3)*n(7)+k143*n(4)*n(6)+k144*n(4)*n(12)+k145*n(6)*n(24)+k146*n(6)*n(22)+k147*n(6)*n(7)+k148*n(9)*n(12)+k149*n(12)*n(13)+k150*n(9)*n(42)+k151*n(15)*n(42)+k152*n(15)*n(42)+k153*n(10)*n(42)+k156*n(18)*n(15)+k157*n(18)*n(16)+k158*n(18)*n(17)+k159*n(20)*n(42)+2*k160*n(20)*n(42)-k1*n(2)*n(42)-k2*n(5)*n(42)-k3*n(8)*n(42)-k59*n(11)*n(42)-k60*n(21)*n(42)-k132*n(1)*n(42)-k133*n(4)*n(42)-k134*n(9)*n(42)-k135*n(13)*n(42)-k150*n(9)*n(42)-k151*n(15)*n(42)-k152*n(15)*n(42)-k153*n(10)*n(42)-k159*n(20)*n(42)-k160*n(20)*n(42)-k161*n(42)*n(4)*n(15)-k162*n(42)*n(4)*n(15);
-k118*n(1)*n(43)-k119*n(3)*n(43)-k120*n(6)*n(43)-k121*n(9)*n(43)-k122*n(11)*n(43)-k123*n(12)*n(43)-k124*n(13)*n(43)-k125*n(14)*n(43)-k126*n(15)*n(43)-k127*n(18)*n(43)-k128*n(19)*n(43)-k129*n(20)*n(43)-k130*n(22)*n(43)-k131*n(24)*n(43)+k1*n(2)*n(42)+k2*n(5)*n(42)+k3*n(8)*n(42)+k61*n(2)*n(1)+k62*n(2)*n(7)+k63*n(2)*n(4)+k64*n(1)*n(13)+k65*n(1)*n(4)+k66*n(1)*n(9)+k67*n(1)*n(5)+k68*n(1)*n(1)+k69*n(1)*n(7)+k70*n(4)*n(4)+k71*n(8)*n(7)+k132*n(1)*n(42)+k133*n(4)*n(42)+k134*n(9)*n(42)+k135*n(13)*n(42)]);
[t,n]= ode45(F,[0:5e-12:1e-7],IC);
plot(t,n)
Good luck.
  5 Comments
Imene Yed
Imene Yed on 22 May 2021
Thank you so much sir for your answers !!!!!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by