ode45 gives time span error

2 次查看(过去 30 天)
Abdelmoumen Bacetti
Abdelmoumen Bacetti 2015-11-18
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by