problem with fit function for data
1 view (last 30 days)
Show older comments
Nirvan Hashemian
on 22 Sep 2021
Commented: Star Strider
on 24 Sep 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 Comments
Accepted Answer
Star Strider
on 22 Sep 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 Comments
More Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!