problem with fit function for data
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Nirvan Hashemian
el 22 de Sept. de 2021
Comentada: Star Strider
el 24 de Sept. de 2021
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.
0 comentarios
Respuesta aceptada
Star Strider
el 22 de Sept. de 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.
.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!