Curve Fitting in MATLAB: Error Diagnosis

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 4K views
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