\section{FORMAT Control the Format of Matrix Display}

\subsection{Usage}

FreeMat supports several modes for displaying matrices (either through the
\verb|disp| function or simply by entering expressions on the command line.  
There are several options for the format command.  The default mode is equivalent
to
\begin{verbatim}
   format short
\end{verbatim}
which generally displays matrices with 4 decimals, and scales matrices if the entries
have magnitudes larger than roughly \verb|1e2| or smaller than \verb|1e-2|.   For more 
information you can use 
\begin{verbatim}
   format long
\end{verbatim}
which displays roughly 7 decimals for \verb|float| and \verb|complex| arrays, and 14 decimals
for \verb|double| and \verb|dcomplex|.  You can also use
\begin{verbatim}
   format short e
\end{verbatim}
to get exponential format with 4 decimals.  Matrices are not scaled for exponential 
formats.  Similarly, you can use
\begin{verbatim}
   format long e
\end{verbatim}
which displays the same decimals as \verb|format long|, but in exponential format.
You can also use the \verb|format| command to retrieve the current format:
\begin{verbatim}
   s = format
\end{verbatim}
where \verb|s| is a string describing the current format.
\subsection{Example}

We start with the short format, and two matrices, one of double precision, and the
other of single precision.
\begin{verbatim}
--> format short
--> a = randn(4)

a = 

   -0.3610    0.1437   -0.6212   -0.8556 
   -0.5851   -0.6293   -0.7944    0.7246 
   -0.7003    3.0445   -0.2511   -0.3654 
   -1.5856    0.4217    0.9614    0.5157 

--> b = float(randn(4))

b = 

   -0.6938   -1.7681    0.2468    0.9813 
    0.3994    1.1454   -0.9926    0.2513 
   -0.4021   -0.7800    0.3820   -1.3138 
   -0.1383   -1.4973   -0.3438    0.9952 


\end{verbatim}
Note that in the short format, these two matrices are displayed with the same format.
In \verb|long| format, however, they display differently
\begin{verbatim}
--> format long
--> a

ans = 

  -0.36104109917203   0.14371748458334  -0.62119867856148  -0.85561084566703 
  -0.58514130479808  -0.62934886335610  -0.79443760799311   0.72456209775698 
  -0.70030658677887   3.04451182288483  -0.25112914812979  -0.36541385410128 
  -1.58558937953551   0.42165459944770   0.96139968715180   0.51566533614799 

--> b

ans = 

  -0.6937948  -1.7681128   0.2468418   0.9813337 
   0.3994139   1.1454117  -0.9926057   0.2513486 
  -0.4021498  -0.7800179   0.3820494  -1.3138303 
  -0.1382517  -1.4973482  -0.3438159   0.9952367 


\end{verbatim}
Note also that we we scale the contents of the matrices, FreeMat rescales the entries
with a scale premultiplier.
\begin{verbatim}
--> format short
--> a*1e4

ans = 

   1.0e+04 * 

   -0.3610    0.1437   -0.6212   -0.8556 
   -0.5851   -0.6293   -0.7944    0.7246 
   -0.7003    3.0445   -0.2511   -0.3654 
   -1.5856    0.4217    0.9614    0.5157 

--> a*1e-4

ans = 

   1.0e-04 * 

   -0.3610    0.1437   -0.6212   -0.8556 
   -0.5851   -0.6293   -0.7944    0.7246 
   -0.7003    3.0445   -0.2511   -0.3654 
   -1.5856    0.4217    0.9614    0.5157 

--> b*1e4

ans = 

   1.0e+04 * 

   -0.6938   -1.7681    0.2468    0.9813 
    0.3994    1.1454   -0.9926    0.2513 
   -0.4021   -0.7800    0.3820   -1.3138 
   -0.1383   -1.4973   -0.3438    0.9952 

--> b*1e-4

ans = 

   1.0e-04 * 

   -0.6938   -1.7681    0.2468    0.9813 
    0.3994    1.1454   -0.9926    0.2513 
   -0.4021   -0.7800    0.3820   -1.3138 
   -0.1383   -1.4973   -0.3438    0.9952 


\end{verbatim}
Next, we use the exponential formats:
\begin{verbatim}
--> format short e
--> a*1e4

ans = 

 -3.6104e+03  1.4372e+03 -6.2120e+03 -8.5561e+03 
 -5.8514e+03 -6.2935e+03 -7.9444e+03  7.2456e+03 
 -7.0031e+03  3.0445e+04 -2.5113e+03 -3.6541e+03 
 -1.5856e+04  4.2165e+03  9.6140e+03  5.1567e+03 

--> a*1e-4

ans = 

 -3.6104e-05  1.4372e-05 -6.2120e-05 -8.5561e-05 
 -5.8514e-05 -6.2935e-05 -7.9444e-05  7.2456e-05 
 -7.0031e-05  3.0445e-04 -2.5113e-05 -3.6541e-05 
 -1.5856e-04  4.2165e-05  9.6140e-05  5.1567e-05 

--> b*1e4

ans = 

 -6.9379e+03 -1.7681e+04  2.4684e+03  9.8133e+03 
  3.9941e+03  1.1454e+04 -9.9261e+03  2.5135e+03 
 -4.0215e+03 -7.8002e+03  3.8205e+03 -1.3138e+04 
 -1.3825e+03 -1.4973e+04 -3.4382e+03  9.9524e+03 

--> b*1e-4

ans = 

 -6.9379e-05 -1.7681e-04  2.4684e-05  9.8133e-05 
  3.9941e-05  1.1454e-04 -9.9261e-05  2.5135e-05 
 -4.0215e-05 -7.8002e-05  3.8205e-05 -1.3138e-04 
 -1.3825e-05 -1.4973e-04 -3.4382e-05  9.9524e-05 


\end{verbatim}
Finally, if we assign the \verb|format| function to a variable, we can retrieve the 
current format:
\begin{verbatim}
--> format short
--> t = format

t = 

 short


\end{verbatim}
