Can you set the name for a fit when you call the cftool(x,y) gui?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm fitting a large number of curves manually from an existing data set (essentially I have them plotted and am going through and looking visually for candidates for power law fits, sometimes only small segments of plots). My code then rips the data out from the existing figure (visible ones only), does some other processing, then dumps the x,y data to the curve fitting toolbox so I can look at/exclude/fit regions depending on how they look (they are not simply straight lines, and the exclusion region changes dynamically each time so its not easy to fit from the command line).
Anyway, all I would like to be able to do is set the fit name at the command line as I add each fit to the gui, but I can't figure out how. Or if it's even possible, I remember searching a few months back, but I just gave up and did it by hand. As there are dozens of sets to fit and the names are a bit convoluted it'd be nice to have a quicker way to do it.
0 commentaires
Réponse acceptée
David Sanchez
le 2 Sep 2013
You can not do it with cftool, but you can code it instead usign fit, like this:
Fit = 'my_fit';
[xData, yData] = prepareCurveData( x, y ); % x/y is your data
% Set up fittype and options.
ft = fittype( 'poly1' ); % choose a different type i
opts = fitoptions( ft );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
% Plot fit with data.
figure( 'Name', Fit );
h = plot( fitresult, xData, yData );
legend( h, 'y vs. x', Fit, 'Location', 'NorthEast' );
% Label axes
xlabel( 'x' );
ylabel( 'y' );
grid on
Plus de réponses (0)
Voir également
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!