I cant figure out whats wrong - but i just cat get this function to work. I have a 2D array of values (256x256) - z
I define X1 as 1x256 vector
Y1 as 1x256 vector
trying to use this, according to an example from the Help Docs:
sf=fit ( [X1,Y1],z,'Exclude', z < 10)
i get abunch of errors which I cant even understand.
Error using fit>iParseOptionalArgs
Algorithm options must be specified in a FITOPTIONS object or as property-value pairs.
Error in fit (line 113)
[useroptions, useroptargs, probparams] = iParseOptionalArgs( varargin{:} );

 Réponse acceptée

Matt J
Matt J le 2 Mai 2022
Modifié(e) : Matt J le 2 Mai 2022
You haven't specified the fit type. Also, your X, Y, and z elements all need to be (256^2)x1 vectors.
[XX,YY]=ndgrid(X1,Y1)
sf=fit ( [XX(:),YY(:)],z(:),fitType, 'Exclude', z < 10)

7 commentaires

Alexander Lazarev
Alexander Lazarev le 2 Mai 2022
Thanks Matt, i need clarification 256 squared? i dont understand..
here is what i tried just now:
X1 is a column vector 256x1 (values are from 1, 2, 3, ... to 256)
Y1 is a row vector 1x256 (values are from 1, 2, 3, ... to 256)
>> sf=fit([X1,Y1],z,'linearinterp','Exclude', z < 100)
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
please help me gt this thing to work )))))
Matt J
Matt J le 2 Mai 2022
Modifié(e) : Matt J le 2 Mai 2022
What happened when you tried what I posted? X,Y, and Z all need to be column vectors of the same length.
Alexander Lazarev
Alexander Lazarev le 2 Mai 2022
>> sf=fit ( [XX(:),YY(:)],z(:),'linearinterp', 'Exclude', z < 10)
Error using curvefit.interpoptions/set
Matrix must be column or row vector.
Error in fitoptions (line 167)
set(f,varargin{:}); % should not allow method to be set.
Error in fit>iGetFitOptions (line 1169)
options = fitoptions(options, useroptargs{:});
Error in fit>iFit (line 178)
options = iGetFitOptions( model, useroptions, useroptargs, warningFcn );
Error in fit (line 116)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
Alexander Lazarev
Alexander Lazarev le 2 Mai 2022
my data array has 256x256 matrix of values...
I am attaching the image of my data here.
I am trying to work on fitting this data with a surface..
Alexander Lazarev
Alexander Lazarev le 2 Mai 2022
repeating this for convenience. Here is what i get if i use the sintax you suggested. (i created XX anf YY per your sintax as well)
>> sf=fit ( [XX(:),YY(:)],z(:),'linearinterp', 'Exclude', z < 10)
Error using curvefit.interpoptions/set
Matrix must be column or row vector.
Error in fitoptions (line 167)
set(f,varargin{:}); % should not allow method to be set.
Error in fit>iGetFitOptions (line 1169)
options = fitoptions(options, useroptargs{:});
Error in fit>iFit (line 178)
options = iGetFitOptions( model, useroptions, useroptargs, warningFcn );
Error in fit (line 116)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
Matt J
Matt J le 2 Mai 2022
Modifié(e) : Matt J le 3 Mai 2022
The Exclude option must also be given input in vector form. From the doc:
Exclude Points to exclude from fit
expression | index vector | logical vector | empty
sf=fit ( [XX(:),YY(:)],z(:),fitType, 'Exclude', z(:) < 10)
Alexander Lazarev
Alexander Lazarev le 5 Mai 2022
thank you it finally worked )))

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange

Produits

Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by