MATLAB Example 1. Hello World

Meas. mode:
Scope
Eye
TDR
Package License:
L-RND
L-SNT

In this MATLAB example, you'll learn how to create the simplest measurement possible to prove your FlexDCA / MATLAB environment. After you finish this example, continue with Example 2.

Do not use spaces or hyphens when selecting a filename for your script.

Procedure

  1. Make sure that you have fullfilled the basic requirements for MATLAB and that you are familiar with the environment for MATLAB scripts.
  2. Copy the following XML listing into a text editor. Name the file HelloWorld.xml and save it in FlexDCA's user measurements folder (\Documents\Keysight\FlexDCA\User Measurements).

Copy

HelloWorld.xml

<?xml version="1.0" encoding="utf-8"?>
    <Measurement xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Script>HelloWorld.m</Script>
    <Name>Hello World!</Name>
    <!-- <Icon>MyPicture.png</Icon> -->
    <ValidMode>Scope</ValidMode>
    <MeasurementType>1 Source</MeasurementType>
    </Measurement>

The <Icon> element is optional. This element allows you to place a picture on your user operator icon.
Example measurement button without
<Icon> element
Example measurement button with
<Icon> element
  1. Copy the following script into MATLAB's editor. Save your script file in FlexDCA's user measurements folder (\Documents\Keysight\FlexDCA\User Measurements) and name it HelloWorld.m. Color in the following script identifies:
    • That Output variables should normally be initialized in your scripts.
    • The input waveform SrcData is missing as the script simply tests if a value can be returned.
    • That output variable, Result, returns a pretend measurement value, 4.2! This is a very simple script that doesn't even calculate a result.

    Copy

    HelloWorld.m

    % These values need to be set by the script.
    % Set Status to Correct only when Result is computed.
    Result = 0.0;
    Status = 'Invalid';
    ErrorMsg = '';
    % Compute Result
    Result = 4.2;
    Status = 'Correct';

    Do not use spaces or hyphens when selecting a filename for your script.

    Enter the above script exactly as written. Otherwise, the script will fail.

  2. Place FlexDCA into Oscilloscope or Eye/Mask modes and display a waveform on the display.
  3. In FlexDCA's User measurement tab, click the User Meas Setup button.
  4. In the dialog, select an available tab.
  5. Click Browse and select your XML configuration file, HelloWorld.xml.
  6. Close the dialog and click on your new Hello World! measurement button.
  7. In the Results pane, notice that the Hello World! measurement result, 4.2 dB, is reported.