Create Plot Example (Visual Basic)

To create the component for this example, see Simple Plot (C#). Then create a Visual Basic® application as follows:

  1. Review the sample application for this example in matlabroot\toolbox\dotnetbuilder\Examples\VSVersion\NET\PlotExample\PlotVBApp\PlotApp.vb.

    The program listing is shown here.

     PlotApp.vb

    The program does the following:

    • Creates two arrays of double values

    • Creates a Plotter object

    • Calls the drawgraph method to plot the equation using the MATLAB® plot function

    • Uses MWNumericArray to handle the data needed by the drawgraph method to plot the equation

        Note:   For information about these data conversion classes, see the MATLAB MWArray Class Library Reference, available in the matlabroot\help\dotnetbuilder\MWArrayAPI folder, where matlabroot represents your MATLAB installation folder

    • Uses a try-catch block to catch and handle any exceptions

    The statement

    Dim plotter As Plotter = New Plotter

    creates an instance of the Plotter class, and the statement

    plotter.drawgraph(coords)

    calls the method drawgraph.

  2. Build the PlotApp application using Visual Studio® .NET.

    1. The PlotVBApp folder contains a Visual Studio .NET project file for this example. Open the project in Visual Studio .NET by double-clicking PlotVBApp.vbproj in Windows® Explorer. You can also open it from the desktop by right-clicking PlotVBApp.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 fix the location of) a reference to the PlotComp component which you built in a previous step. (The component, PlotComp.dll, is in the \PlotExample\PlotComp\x86\V2.0\Debug\distrib subfolder of your work area.)

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

Was this topic helpful?