필터 지우기
필터 지우기

Error from ode15s

조회 수: 3 (최근 30일)
University Glasgow
University Glasgow 2022년 7월 27일
댓글: University Glasgow 2022년 7월 27일
Received this error: Error in ode15s (line 153)
odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Below is my code:
clc
psi = 0.63;
psip = 0.27;
L = 150e-6;
Ts = 60;
k = 0.00158;
q0 = 4.62e3;
C0 =1.03;
gama = 5021.8;
Jw = 8.5e-6;
a = psi*L/Jw/Ts;
b = (1-psi-psip)*k*L/Jw;
e = q0./C0;
d = k*Ts*C0./q0;
%TIME SPAN
tt = 0:100:2400;
t = tt/Ts;
%STEP LENGTH
Nz = 51;
zz= linspace(0, L, Nz);
z = zz./L;
dz = z(2) -z(1);
%IC
IC_A = zeros(1, Nz);
IC_B = zeros(1, Nz);
IC = [IC_A, IC_B];
%Solve the pde using ode15s
[t, c] = ode15s(@f, t, IC, [], Nz, C0, a, b, e, d, dz, gama);
% Extract solutions
C = c(:, 1:Nz);
g = c(:, Nz+1 : 2*Nz);
% Reinput BC
C(:, 1) = 1;
C(:, end) = (4*C(:, Nz-1)-C(:, Nz-2))./3;
%plot
figure(1)
plot(t, C(:, end), '--')
ylim([0 1.2])
function dcqdt = f(t, c, Nz, C0, a, b, e, d, dz, gama)
dcqdt = zeros(length(c), 1);
dcdt = zeros(Nz, 1);
dqdt = zeros(Nz, 1);
%define value
C = c(1:Nz);
g = c(Nz+1 : 2*Nz);
%BC
C(1) =1;
C(end) = (4*C(Nz-1)-C(Nz-2))./3;
%interior for-loop
for i=2:Nz-1
dcdz(i) = C(i+1) - C(i-1)./2./dz; % Using FDA
dcdt(i) = (-1./a).*(dcdz(i) + b.*(gama.*C(i)-q(i).*e));
dqdt(i) = d.*(gama.*C(i)-q(i).*e);
end
dcqdt = [dcdt; dqdt];
end

답변 (1개)

Torsten
Torsten 2022년 7월 27일
편집: Torsten 2022년 7월 27일
psi = 0.63;
psip = 0.27;
L = 150e-6;
Ts = 60;
k = 0.00158;
q0 = 4.62e3;
C0 =1.03;
gama = 5021.8;
Jw = 8.5e-6;
a = psi*L/Jw/Ts;
b = (1-psi-psip)*k*L/Jw;
e = q0./C0;
d = k*Ts*C0./q0;
%TIME SPAN
tt = 0:100:24000;
t = tt/Ts;
%STEP LENGTH
Nz = 51;
zz= linspace(0, L, Nz);
z = zz./L;
dz = z(2) -z(1);
%IC
IC_A = zeros(1, Nz);
IC_B = zeros(1, Nz);
IC = [IC_A, IC_B];
%Solve the pde using ode15s
[t, c] = ode15s(@(t,y)f(t, y, Nz, C0, a, b, e, d, dz, gama), t, IC);
% Extract solutions
C = c(:, 1:Nz);
g = c(:, Nz+1 : 2*Nz);
% Reinput BC
C(:, 1) = 1;
C(:, end) = (4*C(:, Nz-1)-C(:, Nz-2))./3;
%plot
figure(1)
plot(t, C(:, end), '--')
%ylim([0 1.2])
function dcqdt = f(t, c, Nz, C0, a, b, e, d, dz, gama)
dcqdt = zeros(length(c), 1);
dcdt = zeros(Nz, 1);
dqdt = zeros(Nz, 1);
%define value
C = c(1:Nz);
q = c(Nz+1 : 2*Nz);
%BC
C(1) =1;
C(end) = (4*C(Nz-1)-C(Nz-2))./3;
%interior for-loop
for i=2:Nz-1
dcdz(i) = (C(i+1) - C(i-1))./2./dz; % Using FDA
dcdt(i) = (-1./a).*(dcdz(i) + b.*(gama.*C(i)-q(i).*e));
dqdt(i) = d.*(gama.*C(i)-q(i).*e);
end
dcqdt = [dcdt; dqdt];
end
  댓글 수: 4
Torsten
Torsten 2022년 7월 27일
편집: Torsten 2022년 7월 27일
Why is the plot different from what I'm expecting?
Set
tt = 0:100:24000
instead of
tt = 0:100:2400
(see above)
University Glasgow
University Glasgow 2022년 7월 27일
Okay, thank you

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by