Curve fitting problem with X

212 views (last 30 days)
Domitilla Tapinassi
Domitilla Tapinassi on 20 Jul 2015
Edited: Torsten on 21 May 2023
Hi! I got this problem
Error using fit>iFit (line 127)
X must be a matrix with one or two columns.
Error in fit (line 108)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
Error in dio (line 249)
f=fit(x,ls,'poly2');
and i can't understand what i'm doing wrong. X and lmabda_sky are:
lambda_sky=[6115,6145,6172,6385,6416,6605];
X=[3547,3546,3580,3703,3721,3831];
could you please help me??

Answers (1)

Walter Roberson
Walter Roberson on 20 Jul 2015
Your arrays have one row, not one column
f=fit(x(:),ls,'poly2');
  3 Comments
Niklas Kurz
Niklas Kurz on 21 May 2023
Strange behaviour. Why the function doesn't accept row and columns inputs? Like the plot-function or basically any other function that does some array calculations.
Torsten
Torsten on 21 May 2023
Edited: Torsten on 21 May 2023
Strange behaviour. Why the function doesn't accept row and columns inputs? Like the plot-function or basically any other function that does some array calculations.
Because the number of columns for the first input argument is an indicator of whether curve fitting or surface fitting is to be performed. Read the documentation for "fit".

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!