# Why am I getting syntax

1 view (last 30 days)
dwdx=@(X)ks*(((FA0.*(1-X).*R.*T.*y)./(v.*(1+esp.*X)))-(((FA0.*(theta_B+X).*R.*T.*y)/(v.*(1+esp.*X))*((FA0.*(theta_C+X).*R.*T.*y)/(v.*(1+esp.*X)))/(Ke)))/(((1+(KA.*(FA0.*(1-X).*R.*T.*y)./(v.*(1+esp.*X)))+(KB.*(FA0.*(theta_B+X).*R.*T.*y)/(v.*(1+esp.*X)))+(KC.*(FA0.*(theta_C+X).*R.*T.*y)/(v.*(1+esp.*X)))).^2);
I dont know where i go wrong. I keep on getting syntax parentheses error.

Benjamin Thompson on 13 Jun 2022
Missing two closing parenthesis it would appear. Is MATLAB suggestion not correct? You might do better breaking this up into multiple lines using the ... operator notation for easier readability.
>> dwdx=@(X)ks*(((FA0.*(1-X).*R.*T.*y)./(v.*(1+esp.*X)))-(((FA0.*(theta_B+X).*R.*T.*y)/(v.*(1+esp.*X))*((FA0.*(theta_C+X).*R.*T.*y)/(v.*(1+esp.*X)))/(Ke)))/(((1+(KA.*(FA0.*(1-X).*R.*T.*y)./(v.*(1+esp.*X)))+(KB.*(FA0.*(theta_B+X).*R.*T.*y)/(v.*(1+esp.*X)))+(KC.*(FA0.*(theta_C+X).*R.*T.*y)/(v.*(1+esp.*X)))).^2);
dwdx=@(X)ks*(((FA0.*(1-X).*R.*T.*y)./(v.*(1+esp.*X)))-(((FA0.*(theta_B+X).*R.*T.*y)/(v.*(1+esp.*X))*((FA0.*(theta_C+X).*R.*T.*y)/(v.*(1+esp.*X)))/(Ke)))/(((1+(KA.*(FA0.*(1-X).*R.*T.*y)./(v.*(1+esp.*X)))+(KB.*(FA0.*(theta_B+X).*R.*T.*y)/(v.*(1+esp.*X)))+(KC.*(FA0.*(theta_C+X).*R.*T.*y)/(v.*(1+esp.*X)))).^2);
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Did you mean:
>> dwdx=@(X)ks*(((FA0.*(1-X).*R.*T.*y)./(v.*(1+eps.*X)))-(((FA0.*(theta_B+X).*R.*T.*y)/(v.*(1+eps.*X))*((FA0.*(theta_C+X).*R.*T.*y)/(v.*(1+eps.*X)))/(Ke)))/(((1+(KA.*(FA0.*(1-X).*R.*T.*y)./(v.*(1+eps.*X)))+(db.*(FA0.*(theta_B+X).*R.*T.*y)/(v.*(1+eps.*X)))+(KC.*(FA0.*(theta_C+X).*R.*T.*y)/(v.*(1+eps.*X)))).^2)));