Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 287
Creating and Downloading Waveform Files
Programming Examples
% PRESERVE THE BIT PATTERN but convert the waveform to
% unsigned short integers so the bytes can be swapped.
% Note: 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' )
waveform = bitor(bitshift(waveform,-8),bitshift(waveform,8));
end
% Save the data to a file
% Note: The waveform is saved as unsigned short integers. However,
% the acual bit pattern is that of signed short integers and
% that is how the ESG/PSG interprets them.
filename = 'C:\Temp\EsgTestFile';
[FID, message] = fopen(filename,'w');% Open a file to write data
if FID == -1 error('Cannot Open File'); end
fwrite(FID,waveform,'unsigned short');% write to the file
fclose(FID); % close the file
% 3.) Load the internal Arb format file
*********************************
% This process is just the reverse of saving the waveform
% Read in waveform as unsigned short integers.
% Swap the bytes as necessary
% Convert to signed integers then normalize b-1
% De-interleave the I/Q Data
% Open the file and load the internal format data
[FID, message] = fopen(filename,'r');% Open file to read data
if FID == -1 error('Cannot Open File'); end
[internalWave,n] = fread(FID, 'uint16');% read the IQ file
Содержание X-Series
Страница 4: ...4 ...
Страница 10: ...10 Contents ...