Matlab curve fitter error with exponential form with 2 terms
6 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Matt J
2023 年 11 月 11 日
編集済み: Matt J
2023 年 11 月 11 日
% 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 件のコメント
Torsten
2023 年 11 月 11 日
% 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)
その他の回答 (2 件)
Sulaymon Eshkabilov
2023 年 11 月 11 日
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 件のコメント
Sulaymon Eshkabilov
2023 年 11 月 11 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!