Main Content

Generate Signals with the Analog Output Generator

This topic shows how to use theAnalog Output Generatorapp to define and generate signals from an audio device.

To open theAnalog Output Generator, on the MATLAB®Toolstrip, on theAppstab, in theTest and Measurementsection, clickAnalog Output Generator.

Analog Output Generator button

Upon opening, theAnalog Output Generatorattempts to find all your attached analog and audio output devices.

Note

Opening theAnalog Output Generatordeletes all your existing DataAcquisition interfaces in MATLAB.

The DataAcquisition interface created by theAnalog Output Generatoris not accessible from the MATLAB command line.

If you plug in a device while the app is open, you must refresh the listing for access to that device. On theDevicestab, clickRefresh. Use the same procedure to remove a device from the listing after unplugging it.

Select the device you want to use in theDevice List. By default, the app immediately displays a preview of a test signal.

Use the following steps to produce an audio output of the "Hallelujah" chorus from Handel'sMessiah.

  1. Select the device for your output. This might be the primary sound driver, speakers, or a headset.

  2. Load the sound data into the workspace with the following command in MATLAB:

    loadhandel

    This loads two variables into your workspace. The sound data is contained in array namedy. The sampling rate is contained in the variableFs. You will need to know the sampling rate, so display its value.

    Fs
    8192
  3. In the Signal Type section of theAnalog Output Generatortoolstrip, selectWorkspace Variable. In the adjacent selection list, choosey. This indicates the source of the data for the generator to output.

  4. Enter theFsvalue of8192in theRatetext box in theAnalog Output Generator. This indicates the sampling rate. The app should now look something like this.

    Analog Output Generator app configured to output audio

  5. ClickGenerateto produce the sound output.

If you were successful in producing a sound output, try experimenting with some of the settings in the app. For example, modify theRatevalue or theNumber of Cycles.

Tip

If you could not hear any sound, use theTest Signal选项来生成一个不变的基调。检查你所有的hardware connections and different devices in the app until you hear the tone.

In theAnalog Output Generator, clickGenerate Scriptfor the app to open the MATLAB Editor and display the code for producing the signal. The code is generated for the finite (non-continuous) output of this example.

Analog Output Generator generated code

See Also

Apps

Related Topics