Hi,
The error message you are seeing is likely due to the fact that the variable p is not defined before it is used in the code. Specifically, the line am = fsolve(fun2, p(2)/(p(1)+p(2))); is trying to use the value of p before it has been assigned a value.
To fix this error, you can define p before using it in the code.
Hope it helps!