Matlab curve fitter error with exponential form with 2 terms
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Briana Canet
am 11 Nov. 2023
Kommentiert: Torsten
am 11 Nov. 2023
I am trying to curve fit the following data using the following exponetial form with two terms. I was expecting a concave curve along the points, but it is not producting that.
Please help. I am trying to curve fit the following points.
clc;
clear;
close all;
% Interior Square Footage
sqftL = [1500 1600 1750 1930 2250];
sqftUtilityL = [0 0.25 0.5 0.75 1];
0 Kommentare
Akzeptierte Antwort
Matt J
am 11 Nov. 2023
Bearbeitet: Matt J
am 11 Nov. 2023
% Interior Square Footage
x = [1500 1600 1750 1930 2250];
y = [0 0.25 0.5 0.75 1];
theFit=fit(x' , y', 'exp2','Lower',[0 0 -inf -inf],'Upper',[inf 0 0 0 ])
plot(theFit , x , y)
2 Kommentare
Torsten
am 11 Nov. 2023
% Interior Square Footage
x = [1500 1600 1750 1930 2250];
y = [0 0.25 0.5 0.75 1];
theFit=fit(x' , y', 'poly1')
plot(theFit , x , y)
Weitere Antworten (2)
Sulaymon Eshkabilov
am 11 Nov. 2023
It does work very well if the initial conditions are given. Here is how it can be attained:
% Interior Square Footage
sqftL = [1500 1600 1750 1930 2250];
sqftUtilityL = [0 0.25 0.5 0.75 1];
FModel = @(b,x)(b(1)*exp(b(2)*x));
b0=[0.1, 0.001]; % Initial guess for b
opts = statset('Display','iter','TolFun',1e-10);
beta = nlinfit(sqftL,sqftUtilityL, FModel,b0, opts);
x = linspace(min(sqftL), max(sqftL));
FModel_Vals = (beta(1)*exp(beta(2)*x));
plot(sqftL, sqftUtilityL, 'rd', 'MarkerSize',9, 'MarkerFaceColor','y')
hold on
plot(x, FModel_Vals, 'k', 'LineWidth',2)
legend('Data', 'Fit Model: a*exp(b*x)', 'Location', 'best')
xlabel('sqftL')
ylabel('sqftUtilityL & Fit Model')
grid on
1 Kommentar
Sulaymon Eshkabilov
am 11 Nov. 2023
It is better to fit with log fit.
% Interior Square Footage
sqftL = [1500 1600 1750 1930 2250];
sqftUtilityL = [0 0.25 0.5 0.75 1];
FModel = @(b,x)(b(1)*log(x)+b(2));
b0=[1, -1]; % Initial guess for b
opts = statset('Display','iter','TolFun',1e-10);
beta = nlinfit(sqftL,sqftUtilityL, FModel,b0, opts);
x = linspace(min(sqftL), max(sqftL));
FModel_Vals = (beta(1)*log(x)+beta(2));
plot(sqftL, sqftUtilityL, 'rd', 'MarkerSize',9, 'MarkerFaceColor','y')
hold on
plot(x, FModel_Vals, 'k', 'LineWidth',2)
legend('Data', 'Fit Model: a*log(x)+b', 'Location', 'best')
xlabel('sqftL')
ylabel('sqftUtilityL & Fit Model')
grid on
0 Kommentare
Siehe auch
Kategorien
Mehr zu Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!