Modeling concentration using ODE

조회 수: 3 (최근 30일)
Stark Volt
Stark Volt 2021년 9월 26일
답변: Sulaymon Eshkabilov 2021년 9월 29일
I'm trying to model a dye concentration but I cannot make to run and I'm stuck. It gives an error but it will not tell what is wrong. Can any one help thanks?
clear all;
data = load('test_data.dat');
Error using load
Unable to find file or directory 'test_data.dat'.
time = size(data,1);
u = data(:,2);
tspan = [1:1:time];
y0 = data(1,3);
f = -0.25;
g = 0.25;
T = 10.0;
[t,y]=ode45(@model,tspan,y0,f,g,T,U);
plot(t, y(:,end), '*-b', 'LineWidth', 1);
function dydt = model(t,y,f,g,T,u)
if t-1 <= T
u = 0;
else
t_back = t-T;
n = floor(t_back); u =(n);
end
dydt = f*y + g*u;
return;
end
  댓글 수: 9
Stark Volt
Stark Volt 2021년 9월 28일
hello @ Star rider, after I did go through the link you provided which made me read other mathlab knowlegde and documentation so I revise the code that I posted but it I still can't figure out what is wrong. Here are the error poping up thanks.
Not enough input arguments.
Error in cstr_model (line 19)
n = floor(t_back); u= u(n);
Error in odefcncleanup>@(t,y)oldFcn(t,y,inputArgs{:}) (line 11)
newFcn = @(t,y) oldFcn(t,y,inputArgs{:});
Error in ode45 (line 299)
f2 = odeFcn_main(t2, y2);
Error in hw3 (line 33)
[t, x] = ode45(@cstr_model,tspan, y0,f,g,T,u);
**so in the this error newFcn = @(t,y) oldFcn(t,y,inputArgs{:}); what does this mean inputArgs{:}? thank you.
Star Strider
Star Strider 2021년 9월 29일
Please provide a symbolic (preferably LaTeX) version of the differential equation system you’re working with, and the parameters you want to estimate. If you have a PDF of a paper describing what you want to do, that would be even better. (Attach / upload the PDF, not a link to it, because thery’re usually behind a paywall, preventing me from accessing them if I don’t subscribe to the journal.)
Also, putting if blocks in the differential equation function is going to cause problems. Numerical differential equation integration functions don’t do well when integrating across the discontinuities that the if blocks cause.
I don’t understand the reason ‘parameter’ is nowhere represented in the differential equation.
I’ll do my best to see if I can get the differential equation (or system of them) to work with my code and your data.
.

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

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 9월 29일
You had better use this data importing fcn:
data = readmatrix('test_data.dat');
Make sure that the data file (test_data.dat) is present in your current directory or change to the directory where the data file (test_data.dat) is residing.

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by