problem with fit function for data

1 visualizzazione (ultimi 30 giorni)
I have a problem with getting the fit function to work
clear; clc;
E = [416.861, 818.7, 1097.3, 1293.54,1507.4];
e = flip([1.7e-1, 1.6870e-1, 2.045e-1, 1.956e-1, 6.255e-1]);
f = fit(E,e,'exp1');
plot(f,E,e,'rx','markersize',8)
grid on
this gives me this error:
Error in fit (line 116)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
Error in Untitled2 (line 6)
f = fit(E,e,'exp1');
No idea why this happens, and I do have ethe curve fitting toolbox installed.

Risposta accettata

Star Strider
Star Strider il 22 Set 2021
The fit function requires column vector arguments. Force that sith the ‘(:)’ subscript noitation.
E = [416.861, 818.7, 1097.3, 1293.54,1507.4];
e = flip([1.7e-1, 1.6870e-1, 2.045e-1, 1.956e-1, 6.255e-1]);
f = fit(E(:),e(:),'exp1');
hp = plot(f,E,e,'rx');
hp(1).MarkerSize = 8;
grid on
The other problem is that the 'MarkerSize' is ambiguous here, since both the data and fit are plotted, so use that as a separate assignment and reference the appropriate line object.
.

Più risposte (0)

Categorie

Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by