ode45 gives time span error
Afficher commentaires plus anciens
Hello
I want solve a system of 1621x1421 ode for 10 time value each.
I got this error.
##########################################################
*Error using odearguments (line 93) @(T,Z)FCNDT(TT(:),ZZ(:),XX(:)) returns a vector of length 10, but the length of initial conditions vector is 1. The vector returned by @(T,Z)FCNDT(TT(:),ZZ(:),XX(:)) and the initial conditions vector must have the same number of elements.
Error in ode45 (line 114) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in depth_convert (line 41) [T, zz] = ode45(@(t,z)fcndt(tt(:),zz(:),xx(:)),tt(:),0,options);*
##########################################################
Here is the code. Please tell me what al I missing !!!!
t = rand(1621,1421,10);
z = zeros(1621,1421,2);
x = rand(1621,1421,5);
options = odeset('RelTol', 1e-4, 'AbsTol', 1e-4);
%%solve for (i,j) = (1,1)
tic
tt = t(1,1,:);
zz = z(1,1,:);
xx = x(1,1,:);
[T, zz] = ode45(@(t,z)fcndt(tt(:),zz(:),xx(:)),tt(:),0,options);
z(1,1,:) = zz;
toc
%%solve for (i,j) = (100,3)
tic
tt = t(100,3,:);
zz = z(100,3,:);
xx = x(100,3,:);
[T, zz] = ode45(@(t,z)fcndt(tt(:),zz(:),xx(:)),tt(:),0,options);
z(100,3,:) = zz;
toc
function dzdt = fcndt(t,z,x)
dzdt = zeros(1,10);
dzdt = x(1) + x(2) .* z .* (x(3) + cos(x(4).* z + x(5)));
end
Réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!