2.8 Ausgabeformate

Zahlen können in verschiendener Weise am Bildschirm angezeigt werden.
 
    >> s = sin(pi/4)

    s =

        0.7071

    >> format long
    >> s

    s =

        0.70710678118655

    >> format short e
    >> s

    s =

       7.0711e-01

    >> format short
In Tabelle 2.4 auf Seite [*] ist eine Übersicht über die möglichen Parameter von format gegeben. Man beachte, dass man mit dem aus C bekannten Befehl fprintf die Ausgabe viel feiner steuern kann als mit format.

Tabelle 2.4: MATLAB-Formate, siehe help format
Befehl Beschreibung
format short Scaled fixed point format with 5 digits.
format long Scaled fixed point format with 15 digits for double and
  7 digits for single.
format short e Floating point format with 5 digits.
format long e Floating point format with 15 digits for double and
  7 digits for single.
format short g Best of fixed or floating point format with 5 digits.
format long g Best of fixed or floating point format with 15 digits for
  double and 7 digits for single.
format hex Hexadecimal format.
format + The symbols +, - and blank are printed for positive,
  negative and zero elements. Imaginary parts are ignored.
format bank Fixed format for dollars and cents.
format rat Approximation by ratio of small integers.
format compact Suppresses extra line-feeds.
format loose Puts the extra line-feeds back in.


Peter Arbenz 2008-09-24