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
Best Answer