Badly conditioned equations - how can I centre and scale properly
16 views (last 30 days)
Show older comments
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 );
% 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
0 Comments
Accepted Answer
Torsten
on 21 Nov 2023
Edited: Torsten
on 21 Nov 2023
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)
b = alumina_610(:,2);
p = M\b
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
More Answers (0)
See Also
Categories
Find more on Linear and Nonlinear Regression 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!