Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB Builder NE   

Spectral Analysis Example (Visual Basic)

To create the component for this example, see the first few steps of the Spectral Analysis Example. Then create a Microsoft Visual Basic application as follows:

  1. Review the sample application for this example in matlabroot\toolbox\dotnetbuilder\Examples\VS8\NET\SpectraVBApp\SpectraApp.vb.

    The program listing is shown here.

     SpectraApp.vb

    The program does the following:

    • Constructs an input array with values representing a random signal with two sinusoids at 15 and 40 Hz embedded inside of it

    • Uses MWNumericArray to handle data conversion

    • Instantiates a SignalAnalyzer object

    • Calls the computefft method, which computes the FFT, frequency, and the spectral density

    • Instantiates a Plotter object

    • Calls the plotfft method, which plots the data

    • Uses a try/catch block to handle exceptions

    The following statements

    Dim data As MWNumericArray = New MWNumericArray_
        (MWArrayComplexity.Real, MWNumericType.Double, numSamples)
    ...
    Dim resultArray As MWNumericArray = New MWNumericArray_
        (MWArrayComplexity.Complex, MWNumericType.Double, numElements)
    

    show how to use the MWArray class library to construct the necessary data types.

    The following statement

    Dim signalAnalyzer As SignalAnalyzer = New SignalAnalyzer

    creates an instance of the class SignalAnalyzer, and the following statement

    Dim argsOut() As MWArray = signalAnalyzer.computefft
    (3, data, MWArray.op_Implicit(interval))

    calls the method computefft and request three outputs.

  2. Build the SpectraApp application using Visual Studio .NET.

    1. The SpectraVBApp folder contains a Visual Studio .NET project file for this example. Open the project in Visual Studio .NET by double-clicking SpectraVBApp.vbproj in Windows Explorer. You can also open it from the MATLAB desktop by right-clicking SpectraVBApp.vbproj > Open Outside MATLAB.

    2. Add a reference to the MWArray component, which is matlabroot\toolbox\dotnetbuilder\bin\architecture\framework_version
      \mwarray.dll.

    3. If necessary, add (or update the location of) a reference to the SpectraComp component which you built in a previous step. (The component, SpectraComp.dll, is in the \SpectraExample\SpectraComp\x86\V2.0\Debug\distrib subfolder of your work area.)

  3. Build and run the application in Visual Studio .NET.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS