%This function sets the output power level and turns on the synthesizer
% Inputs:
%   Addr: GPIB address of the device (integer 0 to 30)
%   Amp: Output Power Level (in dBm)
% Outputs:

% Equipment it works on:
%   R&S SMB100A

function SigGen_setlevel(Addr,Amp)
%create VISA object (within Matlab operating environment)
%and open it (connect to actual instrument)
address = strcat('GPIB0::', num2str(Addr), '::INSTR');
SigGen = visa('ni', address);
fopen(SigGen)

%set output power level
fprintf(SigGen, 'POW %f dBm', Amp)

% turn on signal generator
fprintf(SigGen, 'OUTP:STAT ON;*WAI')

fclose(SigGen);