Fitting the data without using curve fitting tool

9 vues (au cours des 30 derniers jours)
shaina dhamija
shaina dhamija le 21 Nov 2019
Commenté : Matt J le 16 Déc 2020
Hi. I have a matrix and I have been using the following syntax to fit some data from the matrix z.
[~,~,output] = fit(t,z(:,32),'poly3');
p= output.residuals
The output residuals get stored as output.residuals in the workspace and have to be extracted.
I wish to do the fitting for all the columns in the matrix and use the residuals for all columns in a loop. I wish to put the fitting syntax directly in the loop and not extract output residuals since the loop doesn't run.
  1 commentaire
Matt J
Matt J le 16 Déc 2020
sagi moshe lifshitz's comment moved here:
I have a follow-up question:
I also used the fit() function (on 2017a):
[ fitobject, gof, output ] = fit( [x, y], z, 'poly11' );
plot( fitobject, [x, y], z );
Now in 2020b it isn't working,
The defult function is fit() from machine.learning.toolbox (https://www.mathworks.com/help/stats/lime.fit.html),
and not the regular fit() from curve.fitting.toolbox (https://www.mathworks.com/help/curvefit/fit.html).
The only way to use it is to buy the toolbox? :(

Connectez-vous pour commenter.

Réponses (1)

KSSV
KSSV le 21 Nov 2019
YOu can use polyfit.
p = polyfit(t,z(:,32),3) ;
zi = polyval(p,t) ;

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by