ODE45 and expr function
Show older comments
Hi, I have this problem where I get only the last equation that is executed in the program (%N ) (the expr equations) and I want them to all run together and asign to them names like the comments C ,N,O,.
.............
tic,[t,n] = ode45(@(t,n)myequations(t,n,k1,k2,k3,k4,k5,k6....),[0 10e-3],IC)
toc
%Conservation de la masse:
%C:
expr_at_i(:)= n(:,1) + 2*n(:,9)+2*n(:,10)+3*n(:,13)+...
n(:,22)+n(:,26)+n(:,34)+2*n(:,35)+n(:,36)...
+n(:,37)+2*n(:,39)+4*n(:,40)+5*n(:,41)
%O:
expr_at_i(:)= n(:,4)+2*n(:,15)+2*n(:,16)+2*n(:,17)+n(:,22)...
+n(:,24)+ 3*n(:,29)+n(:,30)+2*n(:,32)+2*n(:,34)+...
n(:,36)+n(:,37)+3*n(:,38)+ n(:,39);
%N
expr_at_i(:)= n(:,7)+2*n(:,20)+n(:,24)+n(:;26)+2*n(:,30)+n(:,32)...
+n(:,35)+n(:,36)+n(:,37)+n(:,38)
function dndt=myequations(t,n,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10.....)
dndt=zeros(43,1);
%Chemin C
dndt(1)= 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)...
%Conservation de la masse:
%C:
expr_at_i(:)= n(:,1) + 2*n(:,9)+2*n(:,10)+3*n(:,13)+...
n(:,22)+n(:,26)+n(:,34)+2*n(:,35)+n(:,36)...
+n(:,37)+2*n(:,39)+4*n(:,40)+5*n(:,41)
%O:
expr_at_i(:)= n(:,4)+2*n(:,15)+2*n(:,16)+2*n(:,17)+n(:,22)...
+n(:,24)+ 3*n(:,29)+n(:,30)+2*n(:,32)+2*n(:,34)+...
n(:,36)+n(:,37)+3*n(:,38)+ n(:,39);
%N
expr_at_i(:)= n(:,7)+2*n(:,20)+n(:,24)+n(:;26)+2*n(:,30)+n(:,32)...
+n(:,35)+n(:,36)+n(:,37)+n(:,38)
Answers (0)
Categories
Find more on Mathematics 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!