%This function resets the Signal generator to its default instrument
%values (-30dBm (output power) and 1000MHz (frequency) and then sets the
%input frequency
% Inputs:
%   Addr: GPIB address of the device (integer 0 to 30)
%   freq: Signal generator c.w. frequency (MHz)
% Outputs:

% Equipment it works on:
%   R&S SMB100A

function SigGen_init(Addr,freq)
%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)

%reset and clear Signal Generator
fprintf(SigGen, '*RST;*CLR;*WAI')

% set frequency of Signal Generator
fprintf(SigGen, 'FREQ %f MHz;*WAI', freq)

fclose(SigGen);
