MATLAB: “Subscript indices must either be real positive integers or logicals.” Error with analytic function

functionsindices

I am trying to write an function, and when I run it, I get this error message. Here is my code,
function p_new = SickleCellModel(p,t,s)
p_new = p+((p(1-p))*(s(1-2*p)+t(1-p))/(1+2*s*p(1-p)-t(1-p)*(1-p)));
end

Best Answer

In MATLAB, you need to put * for every multiplication. Change your statement like this.
p_new = p+((p*(1-p))*(s*(1-2*p)+t*(1-p))/(1+2*s*p*(1-p)-t*(1-p)*(1-p)));