Oscilloscope Reference MATLAB custom functions
When compiling the project, make sure the target p latform is Any CPU. Once the D LL is compiled
(release or debug, both work), it should be placed in the appropriate directory on the instrument. Restart
the instrumen
t application, and the plugin is ready to use like any existing math operator.
MATLAB custom functions
The Custom Analysis Interface for use with MATLAB provides two options for writing MATLAB custom
analysis fu
nctions: a basic function interface and a more advanced class-based interface. Both types are
available in demo form on the instrument in C:\Users\Public\Tektronix\Plugins\Math\MATLAB.
Using the basic Function interface to create MATLAB functions
The function interface uses a simple signature: function [ output ] = exampleProcessingFunction(
firstTime, varargin ) Your function should take two inputs: a Boolean that indicates whether o r not this is
the first time the function has been called and a variable length array. Put the results that you want the
instrument to display into the output variable of the same length as the input array.
If this is the first time the function has been called as part of the math expression, fi rstTime is true. In this
case, t he varargin array consists of the record length and the sample rate:
recordLength = varargin{1};
sampleRate = varargin{2};
and the output is expected to be true:
output = true;
If you have any one time processing, such as filter creation, do this when firstTime is true. If you want
to have variables from a previous execution of the function available, you should m ark the variables
persistent. See the examples for more information. Note that persistent variables are automatically cleared
before the first execution of the function.
If this is not the first time the function has been called, then firstTime is false and varargin will consist of the
waveform inputs. The math expression may have one or two waveform inputs to the MATLAB function:
input1 = varargin{1};
if numel(varargin) == 2
input2 = varargin{2};
end
From here you can do any computations you want and put the results into the output. Your MATLAB
function can use any features available in MATLAB or installed toolboxes to perform its calculations.
Note that the output must have the same length as the inputs. If your output vector is shorter, zero out
the remaining points.
DSA/DPO70000D, MSO/DPO/DSA70000C, DPO7000C, and MSO/DPO5000 Series 757