Error on using ODE45 and cannot prompt output

조회 수: 1 (최근 30일)
Deck Zhan Sim
Deck Zhan Sim 2022년 1월 6일
댓글: Jan 2022년 1월 6일
Hi, i encounter some problem on showing the outputs for ODE45. May i know on how to solve it? I will be grateful that the solutions that provided. Thanks!
Here is the error message:
Error in p2 (line 13)
[t,C_calc]=ode45(first,timespan,C0);
Here is the codes:
clear
close all
clc
k=1000000000;
r = 4.31*(10^-3);
kt=0.9;
D=1;
timespan=[0 30]';
C0=40000;
first=@(t,C) (C*(r-((r-kt*d)/k)*C-(kt*D)));
[t,C_calc]=ode45(first,timespan,C0);
plot(t,C_calc)
hold on
  댓글 수: 3
Deck Zhan Sim
Deck Zhan Sim 2022년 1월 6일
@Ilya Gurin, this is the text given
Error in p2 (line 13)
[t,C_calc]=ode45(first,timespan,C0);
Ilya Gurin
Ilya Gurin 2022년 1월 6일
There's no way that can be the full text.

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

답변 (1개)

Jan
Jan 2022년 1월 6일
I get a different error message, which is very clear:
k=1e9;
r = 4.31e-3;
kt=0.9;
D=1;
timespan=[0 30]';
C0=40000;
first=@(t,C) (C*(r-((r-kt*d)/k)*C-(kt*D)));
[t,C_calc]=ode45(first,timespan,C0);
Unrecognized function or variable 'd'.

Error in solution (line 7)
first=@(t,C) (C*(r-((r-kt*d)/k)*C-(kt*D)));

Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.

Error in ode45 (line 106)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
plot(t,C_calc)
hold on
  댓글 수: 2
Ilya Gurin
Ilya Gurin 2022년 1월 6일
I got that, too, but the OP seems to have a different problem.
Jan
Jan 2022년 1월 6일
As soonas I replace "d" by "D", the code runs and displays a diagram.

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

카테고리

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

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by