%zum Plot der Messdaten und damit für Aufgabe a)
MFile = liste('fullpath');
MPath = fileparts(MFile);
DatFile = fullfile(MPath, liste);
cd f:\uni\  
cd '2. semester'
cd computerpraktikum\übung\13
load liste.dat
x=liste(:,1); y=liste(:,2); 


%Interpolation, für späteres Nullstellenberechnen
p=polyfit(x,y,2); q=polyfit(x,y,1);



%quadratische Funktion
function z=f(s);
MFile = liste('fullpath');
MPath = fileparts(MFile);
DatFile = fullfile(MPath, liste);
load liste.dat
x=liste(:,1); y=liste(:,2);
p=polyfit(x,y,2);
z=polyval(p,s);
end

%lineare Funktion
function z=g(s);
MFile = liste('fullpath');
MPath = fileparts(MFile);
DatFile = fullfile(MPath, liste);
load liste.dat
x=liste(:,1); y=liste(:,2);
q=polyfit(x,y,1);
z=polyval(q,s);
end

"Aufgabe a)"
plot(x,y)
title('Aufzeichnung der 100m-Lauf Messdaten')
xlabel('Jahr')
ylabel('Zeit [s]')
grid on


"Aufgabe b)"
"Quadratische Funktion f(x)=" p
"Lineare Funktion g(x)=" q
plot(p)
title('Approximation via Interpolation einer quadratischen Funktion')
xlabel('Jahr [*10^2]')
ylabel('Zeit [s]')
grid on

plot(q)
title('Approximation via Interpolation einer linearen Funktion')
xlabel('Jahr [*10^3]')
ylabel('Zeit [s]')
grid on


"Aufgabe c)"
"Zur Kontrolle: im Jahr 1930 ist ein Läufer so schnell gelaufen:"
["f(1930)=" f(1930);"g(1930)=" g(1930)]
"Im Jahre 2030 sind sie dann bereits so schnell:"
["f(2030)=" f(2030);"g(2030)=" g(2030)]

"Weitere Prognosen können mit f(Jahreszahl) oder g(Jahreszahl) angestellt werden. Nun weiter zur endlichen 

Prognose, abwann das unmögliche möglich ist:"

"Aufgabe d)"
"Nach der quadratischen Funktion f(x) wird in den Jahren" roots(p) "ein Läufer in 0 Sekunden 100m gelaufen sein!"
"Nach der linearen Funktion g(x) wird im Jahr" roots(q) "ein Läufer 100m in 0 Sekunden zurückgelegt haben."