Technical data

Agilent Signal Generators Programming Guide 277
Creating and Downloading Waveform Files
Programming Examples
unsigned mag_squared;
double rmsDac;
unsigned i;
for (i=0; i<samples; i++)
{
ival = (int)(iq_data[i*2]);
qval = (int)(iq_data[i*2+1]);
mag_squared = (unsigned)(ival*ival) + (unsigned)(qval*qval);
sum_of_squares_accum += mag_squared;
}
// the rms in DAC counts (0 - 32768)
rmsDac = sqrt((double)sum_of_squares_accum / (double)samples);
// convert to normalized form (0 - 1.414).
return rmsDac * 2.0/(double)(DAC_MAX);
}
MATLAB Programming Examples
This section contains the following programming examples:
“Creating and Storing I/Q Data” on page 277
“Creating and Downloading a Pulse” on page 281
“Downloading a Waveform, Markers, and Setting the Waveform Header” on page 284
Playing Downloaded Waveforms on page 290
Creating and Storing I/Q Data
On the documentation CD, this programming example’s name is “offset_iq_ml.m.”
This MATLAB programming example follows the same coding algorithm as the C++ programming
example “Creating and Storing Offset I/Q Data—Big and Little Endian Order” on page 255 and
performs the following functions:
error checking
data creation
data normalization
data scaling
I/Q signal offset from the carrier (single sideband suppressed carrier signal)
byte swapping and interleaving for little endian order data
I and Q interleaving for big endian order data
binary data file storing to a PC or workstation
reversal of the data formatting process (byte swapping, interleaving, and normalizing the data)
function main
%
% Program name: offset_iq_ml
% Using MatLab this example shows how to
% 1.) Create a simple IQ waveform