Filter löschen
Filter löschen

A very simple integration method

3 Ansichten (letzte 30 Tage)
Yara Saavedra Ortega
Yara Saavedra Ortega am 16 Mai 2020
So, I am trying to program a function which creates an array that contains a table with the value of four variables and its derivatives through some time instants. Here's what I've tried. However, it says one of my functions needs additional arguments.
function [integ] = sinteg(P,IC,t,dt)
%This function tries to employ a very simple integration method in order to
%get biomass, Carbon,nitrogen and product concentration.
% P represents a vector including the set of parameters necessary to
% calculate concentrations through the selected interval of time. CI
% represents another vector which contains a set of initial conditions
% for the process. t represents the total lenght of the interval of time
% that wishes to be evaluated. delta t corresponds to the size of the
% finite but next to infinitesimal time step.
inv=t/dt;
integ=zeros(inv,9);
integ(1,1)=0;
integ(1,2)= IC(1);
integ(1,3)= IC(2);
integ(1,4)= IC(3);
integ(1,5)= IC(4);
C=[IC(1),IC(2),IC(3),IC(4)];
aux=de_sys(C,P);
integ(1,6)=aux(1);
integ(1,7)=aux(2);
integ(1,8)=aux(3);
integ(1,9)=aux(4);
i=2;
while i<= t/dt
integ(i,1)=integ(i-1,1)+dt;
for j=1:1:5
integ(i,j)=integ(i-1,j)+integ(i-1,j+4)*dt;
end
aux=de_sys([integ(i,2),integ(i,3),integ(i,4)],P);
for j=6:1:9
integ(i,j)=aux(j-5);
end
i=i+1;
end
Here it is my other function
%This function calculates the value of each derivative for a specific point in time. It needs present conditions and a vector of parameters for the said point in time.
function dDV_dIV = de_sys(C,P)
mumax=P(1);
alpha=P(2);
Ksc=P(3);
Snm=P(4);
a1=P(5);
yxpsc=P(6);
mc=P(7);
Ksn=P(8);
Scm=P(9);
a2=P(10);
yxsn=P(11);
mn=P(12);
X=C(1);
Sc=C(2);
Sn=C(3);
dDV_dIV=zeros(1,4);
dDV_dIV(1)=(mumax*((Sc/(Ksc+Sc))*(Sn/(Ksn+Sn))*(1-(Sc/Scm)^a1)*(1-(Sn/Snm)^a2)))*X;
mu=(mumax*((Sc/(Ksc+Sc))*(Sn/(Ksn+Sn))*(1-(Sc/Scm)^a1)*(1-(Sn/Snm)^a2)));
dDV_dIV(2)=-(((1/yxsn)*mu)+mn)*X;
dDV_dIV(3)=-(((1/yxpsc)*mu)+mc)*X;
dDV_dIV(4)=(alpha*mu)*X;
end
  2 Kommentare
Yara Saavedra Ortega
Yara Saavedra Ortega am 16 Mai 2020
Here's what the error says:
>> sinteg
Not enough input arguments.
Error in sinteg (line 11)
in=(t/dt);
Walter Roberson
Walter Roberson am 16 Mai 2020
When you run sinteg that way, what value should it use for t ? Are you expecting that it will look in the current workspace (the base workspace) to find a variable named t and to use that ?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Devineni Aslesha
Devineni Aslesha am 18 Mai 2020
The error is due to calling the function sinteg without passing any input arguments. Call the function sinteg as shown below.
P = 3*ones(1,12);
IC = [2 1 2 1];
t = 5;
dt = 1;
integ = sinteg(P,IC],t,dt);
For more information, refer the following link.

Weitere Antworten (0)

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by