Badly conditioned equations - how can I centre and scale properly

16 ビュー (過去 30 日間)
A Poyser
A Poyser 2023 年 11 月 21 日
コメント済み: A Poyser 2023 年 11 月 22 日
After writing my own best fit line. I can see that the results are pretty great, however the equation is apparantly badly scaled.
%
alumina_610 = [
25 90
1200 120
1300 150
1350 310
1400 450
1500 790 ];
%%
% % Nextel 610
figure1 = figure;
%
hold on
%
x = (alumina_610(:,1));
y = (alumina_610(:,2));
[xData, yData] = prepareCurveData( x, y );
% Set up fittype and options.
ft = fittype( {'x^12', '100'}, 'independent', 'x', 'dependent', 'y', 'coefficients', {'a', 'b'} );
%
[fitresult, gof] = fit( xData, yData, ft );
Warning: Equation is badly conditioned. Remove repeated data points or try centering and scaling.
% plot fit:
x_fit = linspace(1,1600,100);
y_fit = fitresult(x_fit);
plot(x_fit,y_fit,':r')
% Label axes
xlabel( 'x', 'Interpreter','latex' );
ylabel( 'y', 'Interpreter','latex' );
plot(alumina_610(:,1),alumina_610(:,2),'ro', ...
'MarkerFaceColor','r')
ylim([0 900])
ylabel('Grainsize [nm]','Color',[ 0 0 0 ])
xlim([0 1600])
%
xlabel('Temperature$^{o}$C', 'Interpreter','latex')
% % %
%
How do I correctly scale a best fit line?
Thanks in advance

採用された回答

Torsten
Torsten 2023 年 11 月 21 日
編集済み: Torsten 2023 年 11 月 21 日
Your problem is linear, but fitting data with an independent coordinate up to 1500 by a polynomial of degree 12 is nonsense.
alumina_610 = [
25 90
1200 120
1300 150
1350 310
1400 450
1500 790 ];
M = [alumina_610(:,1).^12 1e38*ones(size(alumina_610,1),1)];
rank(M)
ans = 2
b = alumina_610(:,2);
p = M\b
p = 2×1
1.0e-35 * 0.5620 0.0792
hold on
plot(alumina_610(:,1),alumina_610(:,2),'o')
x = linspace(alumina_610(1,1),alumina_610(end,1),100);
plot(x,p(1)*x.^12+p(2)*1e38)
hold off

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by