Curve Fitting in MATLAB: Error Diagnosis

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 4K views
Science Advisor
Homework Helper
Education Advisor
Insights Author
Messages
1,098
Reaction score
1,385
I have two 1D matrices X(1,j) and Y(1,j) of equal length. To fit Y to a model asin(bx) I tried:
Matlab:
fit = fittype(@(a,b,X), a*sin(b*X));
[fitted, gof] = fit(X, Y, fit)
coefficients = coeffvalues(fitted)
this gives the message: Error using fittype>iDeduceCoefficients
The independent variable x does not appear in the equation expression.
Use x in the expression or indicate another variable as the independent variable.


What's wrong?
 
Physics news on Phys.org
Reply
  • Like
Likes   Reactions: ergospherical