Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (23 sloc) 700 Bytes
format long
T = 0:10:110;
T = T';
pt = [76 92 106 123 137 151 179 203 227 250 281 309];
pt = pt';
f1 = @(T) T.^3;
f2 = @(T) T.^2;
f3 = @(T) T;
f4 = @(T) ones(length(T),1);
A = [f1(T), f2(T), f3(T), f4(T)];
lambda = (A'*A)\(A'*pt);
p = @(T) lambda(1).*T.^3 + lambda(2).*T.^2 + lambda(3).*T + lambda(4);
A = [f2(T), f3(T), f4(T)];
lambda = (A'*A)\(A'*pt);
p2 = @(T) lambda(1).*T.^2 + lambda(2).*T + lambda(3);
disp(norm(pt-p(T),2)^2);
disp(norm(pt-p2(T),2)^2);
% Das Fehlerfunktional des ersten Polynoms ist kleiner, deshalb ist das
% Polynom p1 optimaler, als das Polynom p2
plot(T,pt,'o',T,p(T),'r', T,p2(T), 'g --');
legend('Datenpunkte', 'p', 'p2');
xlabel('T [yr]');
ylabel('p(t) [Mio]');
You can’t perform that action at this time.