Code covered by the BSD License  

Highlights from
Agilent Spectrum Analyzer Seminar Examples

image thumbnail
from Agilent Spectrum Analyzer Seminar Examples by Richard Overdorf
Agilent MXA, PSA Seminar Examples

MXA_AcquireData( handle )
function data = MXA_AcquireData( handle )
% MXA_AcquireData Triggers a sweep and reads back the trace.
%

global g_MXASampleData
global g_MXACurrentIndex
global g_MXASimulate

if g_MXASimulate == 0 
    %*---------------------------------------------------*
    %  Live mode
    %*---------------------------------------------------*
    % Trigger a sweep and wait for completion
    fprintf( handle, 'INIT:IMM; *WAI;' );

    % Read back the trace data
    fprintf( handle, 'TRAC:DATA? TRACE1' );
    data = binblockread( handle, 'float' );
    fread(handle,1);

else
    %*---------------------------------------------------*
    %  Debug mode
    %*---------------------------------------------------*
    % Return the next waveform in the simulated acquisition
    g_MXACurrentIndex = g_MXACurrentIndex + 1;
    if g_MXACurrentIndex > size( g_MXASampleData, 2 );
        g_MXACurrentIndex = 1;
    end
    data = g_MXASampleData( :, g_MXACurrentIndex );
    
end

Contact us at files@mathworks.com