MATLAB Answers

Incorrect use of '=' operator. Assign a value to a variable using '=' and compare values for equality using '=='.

32 views (last 30 days)
Nadya Shalsabila salman
Nadya Shalsabila salman on 24 Oct 2021
Asking for help.
File: trycurvefitI.m Line: 45 Column: 17
ERROR "Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='."
I already followed instruction above but my dcdt(2) plot become a linear line.Any little suggestion or solutions or comments are very welcomed! Thank you so much!
This is my code
function trycurvefit
function C=kinetics(theta,t)
c0=[0.1143; 0.9659; 0.04406];
[T,Cv]=ode45(@DifEq,t,c0);
%
function dC=DifEq(t,c)
z = [1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20];
j = 1;
for j = 1 : 20
if z(j) <= 4
I = 45;
elseif z(j) <= 7
I = 90;
elseif z(j) <= 11
I = 120;
elseif z(j) <= 15
I = 150;
else
I = 180;
end
dcdt=zeros(3,1);
dcdt(1)= (theta(1).*(c(2)/(theta(2)+c(2)+(c(2).^2/theta(3))))*(I/(theta(4)+I)).*(1-c(1)/theta(5)).*(1-c(3)/theta(6)));
-dcdt(2)=(1/theta(7).*dcdt(1))+(1/theta(8).*dcdt(3))+(theta(9).*c(1));
dcdt(3)= (theta(10).*dcdt(1)+theta(11).*c(1)).*(c(2)./(theta(12)+c(2)+(c(2).^2/theta(13)))).*(c(3)/(theta(14)+c(3))).*(I/(theta(15)+I));
dC=dcdt;
end
end
C=Cv;
end

Answers (1)

Steven Lord
Steven Lord on 24 Oct 2021
-dcdt(2)=(1/theta(7).*dcdt(1))+(1/theta(8).*dcdt(3))+(theta(9).*c(1));
Assigning to element 2 of the variable dcdt is allowed.
Assigning to the expression -dcdt(2) is not allowed.
Either eliminate the - entirely or move it to the right side (essentially multiply both sides of the line of code by -1.)
  5 Comments
Nadya Shalsabila salman
Nadya Shalsabila salman on 26 Oct 2021
@Steven Lord I have tried to specifying the tspan, but still not work. I think the problem more complicated and i still don't get it to solve this. It will be my pleasure if you could help me out about my problem.
*Note: below is the problem i want to simulate in matlab. if there is an fault in my code, please let me know
I am trying to plot graphs (Substrate vs time, Biomass vs time, and Product vs time) from these modified kinetic equations below:
dX/dt = miumax * S/(Ks*S*(S^2/Kxi)) * I/(KXI+I) * (1-X/Xm) *(1-P/Pm)
-dS/dt = 1/Yxs*(dX/dt) + 1/Yps*(dP/dt) + miusx*X
dP/dt = (Ypx*(dX/dt) + miupx*X) * S/(Kps+S+(S^2/Kpi)) * P/(Kp+P) * I/(KPI+I)
where miumax, Ks, Kxi, KXI, Xm, Pm, Yxs, Yps, miusx, Ypx, miupx, Kps, Kpi, Kp, and KPI are kinetic parameters; S, X, P are substrate concentration, biomass concentration, and product concentration respectively. Besides the graphs, i also want to have the kinetic parameters as the output. The initial concentrations for each X, S, and P are 0.1143; 0.9659; 0.004406

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!