Probles with Subscript indices must either be real positive integers or logicals. Error in Untitled3 (line 144) dp1dt(i)=(​-((F1+F2)/​V(i))*dp1d​t(i)+(ki(E​SHM))-(km2​*(dp1dt(i)​*M(i)))+kp​*(dp2dt(k)​*A-kt*dp1d​t(i)));%Lu​mped Molar balances

2 views (last 30 days)
Can anyone help me with next code?
clear all clc
Param=[4.3276103255301335 0.10215543561231799 12.346130949956718 0.04565511507929096 0.0074744247798137625 0.0022142903501092513 1.6957452439712215 0.008166212885461337 0.028435528710812962 6.156650857937292 2.0566837008694536 0.9088238699999999 0.8669780915448081 8.072715437027492 0.010453310496367572 5.260491048 5.325728554979126 6.837140753063702 0.03947867100809781]; Optim=[1.4989542634814161 1.4335418277418217 1.5744495703184183 0.2559519340674219 0.7975221812123433 1.3319125502728477 1.1153538963112686]; Sens=[0.5 0.973342635 2 8.827704916 0.87519757 1.2];
% Parameters for Fed-Batch Models um=0.54*Param(1)*0.6*0.6*0.5*Optim(1);%h^-1 tomada de Development of a structure dynamic model Ksr=0.15*Param(2); %adimensional saturation constant for the inhibition due to N/C, tomada de Simulation and optimization of PHB Sm=0.3*Param(3)*Optim(2);%adimensional, relación N/C a la cual miu es cero tomada de Simulation and optimization of PHB Csx=1.7640*Param(4)*0.59*25*Optim(3);%gS/gX taken from model baed fed batch cultivation as the a value Rcsx=0.022*Param(5)*Optim(4);%*50Sucrose specific consumption rate for respiration/maintenance for the residual biomass (g/gh) Csp=1.7460*Param(6);%gS/gP taken from model based fed batch cultivation as the b value k1=0.14*Param(7)*1.5*Optim(5);%gP/gX taken from model based fed batch cultivation as the e value k2=0.74*Param(8);%gP/gX h taken from development of a structured Cnx=0.336*Param(9);%gN/gX h taken from updated mathematical model and fedbatch as the parameter d KL=0.1*Param(10);%1/h taken as constant from development of a structured dynamic model k3=93*Param(11);%gO2/gX taken from development of a structured dynamic model k4=85*Param(12);%gO2/gP taken from development of a structured dynamic model the parameter was k5 O2Leq=7.6*10^-3*Param(13);%taken from development of a structured dynamic model as O2loeq nk=1.22*Param(14)*Optim(6);%adimensional exponent on the kinetic expression taken from simulation and optimisation Rcnx=0.16*Param(15)*Optim(7);%taken from mode based dynamic optimization alfa1=0.143*Param(16); %mmolCO2/g biomass alfa2=0.0000004*Param(17); %mmolCO2/ g biomass h alfa3=0.0001*Param(18); %mmolCO2/lh Kox=0.02*Param(19); %gO2/gX Taken from A modular simulation package for fed-batch fermentation: penicillin production
%Parameters for polymerization model ki=0.62*10^4; kp=0.46*10^5; kt=0.14*10^1; km1=0.11*10^-3; km2=0.86*10^7; kd=0.83*10^2;
%Initial Conditions validation data X(1)=1.16;%0.433743333333333;%active biomass g/L S(1)=20.05;%43.4579133333333*Sens(1); %fructose g/L N(1)=2;%0.577887666666667*Sens(2);%Nitrogen g/L P(1)=1.01;%0.136603333333333;%PHA g/L O2L(1)=0.002432; CO2(1)=0.01; V(1)=4; V1(1)=0; V2(1)=0;
%Initial Conditions for polymerization M(1)=0; ESHM(1)=0; dp1dt(1)=0; dp2dt(1)=0; dDdt(1)=0;
F3=0.1; Sin=300*Sens(3);%g/L Fructose Cocentration in the feeding Nin=7*Sens(4); %g/L Nitrogen concentration in the feeding O2in=0.002432; %g/L
Yms=3.48*10^-3;%calculado con los datos iniciales del papaer Jf=0.2818; %initial iteration for substrate Jm=Yms*Jf;
%Specific growth rate u(1)=um*((N(1)/S(1))/((N(1)/S(1))+Ksr))*(1-((N(1)/S(1))/Sm)^nk)*((O2L(1)/(Kox*X(1)+O2L(1))));
tsim=50; t(1)=0; dt=0.001; i=1;
Nt=50;%for fixed pivot method
% Euler Method for ODE´s solution while t(i)<tsim
if t(i)<6
F1=0;
F2=0;
elseif t(i)>6 && t(i)<10
F1=0;
F2=70*(1/1000)*Sens(5);
Fobj31=1.3*F2*4;
elseif t(i)>10 && t(i)<16
F1=80*(1/1000)*Sens(6);
F2=70*(1/1000)*Sens(5);
Fobj32=3.2*F1*6+1.3*F2*6;
elseif t(i)>16 && t(i)<20
F1=80*(1/1000)*Sens(6);
F2=0;
Fobj33=3.2*F1*4;
Fobj3=Fobj31+Fobj32+Fobj33;
else
F1=0;
F2=0;
end
V(i+1)=V(i)+(F1+F2)*dt;
V1(i+1)=F1;
V2(i+1)=F2;
% Fed-Batch States
X(i+1)=X(i)+(u(i)*X(i)*dt-((F1+F2)/V(i))*X(i)*dt);%Biomass
S(i+1)=S(i)-((Csx*u(i)*X(i))+(Rcsx*X(i))+Csp*((k1*u(i)*X(i))+(k2*X(i))))*dt+(F1/V(i))*Sin*dt-((F1+F2)/V(i))*S(i)*dt;%Carbon Source
P(i+1)=P(i)+((k1*u(i)*X(i))+(k2*X(i)))*dt-((F1+F2)/V(i))*P(i)*dt;%Polymer
N(i+1)=N(i)-((Cnx*u(i)*X(i))+(Rcnx*X(i)))*dt+(F2/V(i))*Nin*dt-((F1+F2)/V(i))*N(i)*dt;%Nitrogen Source
if N(i+1)<0.15
N(i+1)=0.15;
end
O2L(i+1)=O2L(i)+((KL*(O2Leq-O2L(i)))-(k3*u(i)*X(i))-((k4*k1*u(i)*X(i))+(k4*k2*X(i))))*dt+(F3/V(i))*O2in*dt-((F1+F2)/V(i))*O2L(i)*dt;%Dissolved Oxygen
if O2L (i+1)<0.002432
O2L(i+1)=0.002432;
end
CO2(i+1)=CO2(i)+((alfa1*u(i)+alfa2)*X(i)*dt)+(alfa3*dt)-((F1+F2)/V(i))*CO2(i)*dt;%Dissolved CO2
u(i+1)=um*((N(i+1)/S(i+1))/((N(i+1)/S(i+1))+Ksr))*(1-((N(i+1)/S(i+1))/Sm)^nk)*((O2L(i)/(Kox*X(i)+O2L(i))));
if u(i+1)<0
u(i+1)=0;
end
%se quita acá
% t(i+1)=t(i)+dt;
% i=i+1;
%
% end %hasta acá
%Monomer and Complex definition
ESHM(i+1)=ESHM(i)+(-((F1+F2)/V(i))*ESHM(i)*dt+(km1*M(i)*dt)-(ki*(ESHM(i)*dt))); %Synthase-Monomer Complex
dp1dt(1)=1;%
for n=1:Nt
M(i+1)=M(i)+ (-((F1+F2)/V(i))*M(i)*dt+(-((Csx*u(i)*X(i))+(Rcsx*X(i))+Csp*((k1*u(i)*X(i))+(k2*X(i))))*Yms)-(km1*M(i)*dt)-(km2*M(i)*dp1dt(n))*dt); %Monomer (revisar acá dp1dt(n))
% t(i+1)=t(i)+dt; % i=i+1; % end % end % % % %Polymerization Equations % % % Revisar acá for i=1:Nt % for k=1:j dp1dt(i)=(-((F1+F2)/V(i))*dp1dt(i)+(ki(ESHM))-(km2*(dp1dt(i)*M(i)))+kp*(dp2dt(k)*A-kt*dp1dt(i)));%Lumped Molar balances equations for the active polymer chain dp2dt(i)=(-((F1+F2)/V(i))*dp2dt(i)+(km2*(dp1dt(i)*M(i)))-(kp(dp2dt(i)))); %Lumped Molar balance equation for the intermediate polymer chain dDdt(i)=(-((F1+F2)/V(i))*dDdt(i)+(kt*dp1dt(i))-(kd*dDdt(i))+(kd*(dDdt(k)*B))); %Lumped molar balance equation for the inactive polymer chain end end t(i+1)=t(i)+dt; i=i+1; end
% end

Accepted Answer

Image Analyst
Image Analyst on 1 Nov 2015
Reading the FAQ is the best way to understand the reason for this error: http://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F After you read this, you will know how to solve your problem. If you still don't, then see this link and this one.

More Answers (0)

Categories

Find more on Chemistry in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!