generate signals with analog output generator -凯发k8网页登录

main content

generate signals with analog output generator

this topic shows how to use the analog output generator app to define and generate signals from an audio device.

to open the analog output generator, on the matlab® toolstrip, on the apps tab, in the test and measurement section, click analog output generator.

analog output generator button

upon opening, the analog output generator attempts to find all your attached analog and audio output devices.

note

opening the analog output generator deletes all your existing dataacquisition interfaces in matlab.

the dataacquisition interface created by the analog output generator is 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 the devices tab, click refresh. use the same procedure to remove a device from the listing after unplugging it.

select the device you want to use in the device 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's messiah.

  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:

    load handel

    this loads two variables into your workspace. the sound data is contained in array named y. the sampling rate is contained in the variable fs. you will need to know the sampling rate, so display its value.

    fs
    8192
  3. in the signal type section of the analog output generator toolstrip, select workspace variable. in the adjacent selection list, choose y. this indicates the source of the data for the generator to output.

  4. enter the fs value of 8192 in the rate text box in the analog output generator. this indicates the sampling rate. the app should now look something like this.

    analog output generator app configured to output audio

  5. click generate to 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 the rate value or the number of cycles.

tip

if you could not hear any sound, use the test signal option to generate a constant tone. check all your hardware connections and different devices in the app until you hear the tone.

in the analog output generator, click generate script for 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

网站地图