Contents

CompMath: Vorlesung 5.10.2017

Umrechnung von Einheiten - Vektorvariante
clear; clc
c = -5:5:35;            % erzeugt vektor [-5 0 5 10 15 20 25 30 35]
[k,f] = c2kf(c);        % ruft Funktion c2kf mit Vektor als Input auf, Vektoren als Output

huebsche Ausgabe fuer (Zeilen-)Vektoren

disp([num2str(c),' °Celsius entsprechen:']);
disp([num2str(k),' Kelvin']);
disp([num2str(f),' °Fahrenheit']);
-5   0   5  10  15  20  25  30  35 °Celsius entsprechen:
268.15        273.15        278.15        283.15        288.15        293.15        298.15        303.15        308.15 Kelvin
23  32  41  50  59  68  77  86  95 °Fahrenheit

Plot

plot(c,f,'-bs',c,k,'-ro')
xlabel('Grad Celsius')
legend('Fahrenheit','Kelvin')
title('Temperaturumrechnung')

Berechnung ident zu oben, aber mit einem Loop (Zaehlzyklus)

n = length(c);           % Anzahl der Elemente im Vektor c
for s=1:n
    %  k(s) - s-tes Element des Vektors k
    [ k(s), f(s) ] = c2kf( c(s) );  % rufe Funktion c2kf fuer jedes Vektorelement einzeln auf
end

%publish('celsius_vek')