Fitting data polynomial fitlm
Mostrar comentarios más antiguos
I am trying to fit data, first to a polynomial of degree 1 and then to a polynomial of degree 1 but log(y) instead of y. How make a predicting to what the data would look like the year 2020 and plot it? (The first x-value is 1972 and it increases with 1 until 2011)
clear all
clf
load moore.mat %xtime and y are 40x1 double
%data for mooores law
%polynomial of degree 1
figure(13)
mdl1 = fitlm(xtime,y)
subplot(2,1,1)
plot(mdl1,'Color','m')
hold on
ttime = 1972:1:2020;
T = [];
for j=1972:1:2020
t = ((j.*4.4366.^20) -8.8006^10);
T = [T t];
end
plot(ttime,T)
%polynomial of degree 1 mwith log y instead of y
mdl3 = fitlm((xtime),log(y));
%maybe I should use predict
%R^2 för modellerna -> this I get with fitlm
%transforming the logarithmically fitted version back to normal
%using data from fitlm
Y = [];
for i=1972:1:2020
y_ny = (i.*0.52342-1030.3);
Y = [Y y_ny];
end
xtime_ny = 1972:1:2020;
%Får ut med fitlm i cmd window
subplot(2,1,2)
plot(xtime_ny,Y,'c-*')
legend('label1')
%are the residuals normally distributed, investigate with qqplot
%making a new plot with a prediction in year 2020 (the x data is in years)
%this plot is supposed to be with the polynomial of the first degree...
%...and the polynomial that used the logaritm
%look at graphs for the year 2020
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Linear and Nonlinear Regression en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!