64 lines
1.2 KiB
Matlab
64 lines
1.2 KiB
Matlab
function main();
|
|
|
|
% Main function for iteration of static values in
|
|
% eigenvalue problem
|
|
%
|
|
%
|
|
% Grundlagen der Modellierung und Simulation
|
|
% WiSe 2012/13
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%% Start Values %%%%%%%%%%%%%%%%%%%%
|
|
|
|
x = [-3; 0; 0]
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
x_fixpunkt = x;
|
|
x_newton = x;
|
|
x_qnewton = x;
|
|
|
|
%%%%%%%%%%%%%%%%%%% Fixpunkt %%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
[it_f, x_f] = fixpoint(x_fixpunkt);
|
|
|
|
%%%%%%%%%%%%%%%%%%% Newton %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
[it_n, x_n] = newton(x_newton);
|
|
|
|
%%%%%%%%%%%%%%%%%%% Quasi-Newton %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
[it_qn, x_qn] = quasi_newton(x_qnewton);
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%% Output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
disp('Startwert x');
|
|
x
|
|
|
|
disp('Anzahl Iterationen bei Fixpunkt:');
|
|
it_f
|
|
disp('Loesung:');
|
|
x_f(:,it_f)
|
|
%x_f
|
|
|
|
disp('Anzahl Iterationen bei Newton:');
|
|
it_n
|
|
disp('Loesung:');
|
|
x_n(:,it_n)
|
|
%x_n
|
|
disp('Anzahl Iterationen bei Quasi-Newton:');
|
|
it_qn
|
|
disp('Loesung:');
|
|
x_qn(:,it_qn)
|
|
|
|
|
|
semilogy(1:it_n, abs(x_n(3,:)-2), ...
|
|
1:it_f, abs(x_f(3,:)-2), ...
|
|
1:it_qn, abs(x_qn(3,:)-2))
|
|
title('Iterationsverfahren');
|
|
legend('error (Newton) ','error (FixP)','error (Quasi-Newton)')
|
|
xlabel('Anzahl Iterationen');
|
|
ylabel('Fehler in lambda');
|
|
|