%***************************************************
%   Sample MATLAB program illustrating different 
%   data formats in MATLAB and display styles
%   and saving to files
%   Filename: dat_form.m 
%   AUTHOR: Balu Santhanam
%   DATE  : 01/18/2001
%   EECE-495, Spring Semester, 2001
%***************************************************
% Input Data for Example
T_c = [-50:10:100]; 
T_f = (9/5)*T_c + 32; 
T_k = T_c + 273.16;
%  Data in long format 
%  Scaled fixed point 15 digit format
format long
display('Data in Fixed-15 Format')
display([T_c.' T_f.' T_k.'])
pause(2)
%  Scaled fixed point 5 digit format 
format short 
display('Data in Fixed-5 Format')
display([T_c.' T_f.' T_k.'])
pause(2)
%  Floating Point 5 digits
format short e 
display('Data in Float-5 Format')
display([T_c.' T_f.' T_k.'])
pause(2)
%  Floating Point 15 digits
format long e 
display('Data in Float-15 Format')
display([T_c.' T_f.' T_k.'])
pause(2)
%  Bank Format
%  Two decimal places for cents
format bank
display('Data in Bank Format')
display([T_c.' T_f.' T_k.'])
pause(2)
%  Rat Format
%  Approximation by rational numbers
format rat
display('Data in Rat Format')
display([T_c.' T_f.' T_k.'])
pause(2)
%  Alternative display using fprintf
format long
diary temper
fprintf('********************************************************\n')
fprintf('%s\t\t |  %s\t\t |  %s\t\n','Celcius','Farenh','Kelvin')
fprintf('********************************************************\n')
fprintf('%3.2f\t\t | %3.2f\t\t | %3.2f\n',[T_c  ; T_f  ; T_k ])
fprintf('********************************************************\n')
diary off
save temper.mat T_c T_f T_k

