
Using MATLAB's Interface for External Libraries
1MA171_5e Rohde & Schwarz How to use Rohde & Schwarz Instruments in MATLAB
®
18
The library is loaded using following sequence:
%% load library of R&S 32-bit instrument driver
vxipnpLib = 'rsspecan_32';
vxipnpLibDll = 'rsspecan_32.dll';
vxipnpHeader = 'rsspecan.h';
if ~libisloaded (vxipnpLib)
loadlibrary(vxinpnLibDll, vxipnpHeader);
end
In this example, the rsspecan instrument driver is used. The variables vxipnpLib and
vxipnpLibDll can be reassigned to refer any other Rohde & Schwarz VXIplug&play
instrument driver library. After this step, the referred library is ready to be used in
MATLAB
®
.
Acquiring information about the libraries
The following functions are available for acquiring more information about the library
and its application programming interface (API):
>> libfunctions(vxipnpLib, '-full');
>> libfunctionsview(vxipnpLib);
The most important information is that about the signatures of the library function calls.
This information makes it easy to gain an understanding of necessary function
parameter types.
3.4 Calling Library Functions
Calling functions from libraries is a critical task, because MATLAB
®
has a different data
representation than the ANSI C programming language.
A trace from a Rohde & Schwarz spectrum analyzer can be captured by using the
following MATLAB
®
example code snippet:
%% read trace
instr_sweepPoints = 501; % amout of sweep points
instr_trace = 1; % trace window
instr_timeoutMs = 15000; % measurement timeout
instr_arrayLen = instr_sweepPoints;
% max amount of meas. values
instr_arrayActualLen = -1; % actual amount of meas. values
instr_amplitude = zeros(instr_arrayLen,1);
% meas. values
[err, instr_arrayActualLen, instr_amplitude] =
calllib(vxipnpLib,
'rsspecan_ReadYTrace', instr_session, instr_window,
instr_trace, instr_timeoutMs, instr_arrayLen,
instr_arrayActualLen, instr_amplitude);
% function call into library
Comentarios a estos manuales