From the doc: "nlintool(X,y,fun,beta0) is a graphical user interface to the nlinfit function, and uses the same input arguments"
IOW, nlintool is just a user-friendly front-end to the nlinfit function.
The error is a standard MATLAB error for array operations versus matrix operations. Multiply, divide, and exponentiation are all interpreted in a matrix sense; to use an array operation (ie element-by-element), precede the operator with a dot:
chris = b1-b1*(X/b2).^b3;
Beyond that, you're also going to run into other problems, so let me make a preemptive strike...
Don't define your data in this function!
X and beta are passed in to the function as arguments. Y isn't needed at all here. The function simply defines the model you're trying to fit. Given a value of X and parameters beta, it should return the value of the model you're fitting (ie yhat = beta1 - beta*(X/beta2)^beta3).
It is nlinfit that needs the measured X and Y data values. It ( nlinfit ) uses these to compare the model's predictions for the given X values to the given Y values. It then adjusts the parameters to get the best fit.
So: remove all data from the function. Move them into a separate script. Then, in that script, call nlinfit with an initial guess for beta ( beta=[1.4 0.537 1.1] ).
Best Answer