필터 지우기
필터 지우기

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