TU Wien:Computernumerik VU (Schranz-Kirlinger)/Übungen SS16/Beispiel 2

Aus VoWi
Zur Navigation springen Zur Suche springen

Lösung[Bearbeiten | Quelltext bearbeiten]

cosinusdata.csv

Matlab Code:

function Bsp2

data = csvread('cosinusdata.csv');

signal = data(:,2);
values = data(:,1);

%% a
exact = cos(values);
absErr = signal - exact;
relErr = absErr / exact;

figure('Name', 'a.Absolut');
plot(values, absErr);
set(gca,'YScale','log');

figure('Name', 'a.Relativ');
plot(values, relErr);
set(gca,'YScale','log');

%% b
exact = real(acos(signal));
absErr = values - exact;
relErr = absErr / exact;

figure('Name', 'b.Absolut');
plot(signal, absErr);
set(gca,'YScale','log');

figure('Name', 'b.Relativ');
plot(signal, relErr);
set(gca,'YScale','log');
end