303
aPPenDix B
wav eform = round(waveform * 32767); % Data is now
effectively signed short integer values
% w aveform = round(waveform * (32767 /
max(abs(waveform)))); % More efficient than
previous twosteps!
% PRESERVE THE BIT PATTERN but convert the waveform to
% unsigned short integers so the bytes can be swapped.
% N ote: Can't swap the bytes of signed short integers
in MATLAB.
Waveform = uint16(mod(65536 + waveform,65536)); %
% If on a PC swap the bytes to Big Endian
if strcmp( computer, 'PCWIN')
wav eform = bitor(bitshift(waveform,-8),
bitshift(waveform,8));
end
% Save the data to a file
% N ote: The waveform is saved as unsigned short
integers. However,
% t he acual bit pattern is that of signed short
integers and
% that is how the Agilent MXG/ESG/PSG ...