Matlab-Redes Neuronales
Matlab-Redes Neuronales
Overview
This tutorial provides detailed information on working with the MathScript Node as part of the LabVIEW MathScript RT Module.
Table of Contents
1. What Is the LabVIEW MathScript RT Module?
2. How Do I Use the MathScript RT Module?
3. Step-by-Step Example
4. Script Highlighting
5. Debugging Your Code Within the MathScript Node
6. What Does This Yellow Exclamation Point Glyph Mean?
3. Step-by-Step Example
This example assumes that you have basic experience working with LabVIEW. (Read the product information page for more details on working with the LabVIEW graphical development
environment.) This example creates a sinusoid, executes a fast Fourier transform (FFT) on that sinusoid, and then outputs both graphs to a LabVIEW front panel.
1. Create a new VI.
2. Create a Vertical Pointer Slide (Controls Modern) named Amplitude on the front panel.
3. Create two Waveform Graphs (Controls Graph) named Sinusoid and FFT Analysis on the front panel.
Figure 2. This shows the completed front panel for the example VI.
1/6
www.ni.com
Figure 2. This shows the completed front panel for the example VI.
4. Select Window Show Block Diagram to display the block diagram of the VI.
5. On the block diagram, select View Functions Palette to display the functions palette.
6. Move the cursor over the icons on the programming palette to locate the structures palette.
7. Click the structures icon to display the structures palette.
8. Move the cursor over the icons on the structures palette to locate the MathScript Node.
9. Click the MathScript Node icon.
10. On the block diagram, click and drag the mouse in a rectangular shape to place the MathScript Node.
Figure 3. Place a MathScript Node on the block diagram by clicking and dragging the mouse in a rectangular shape.
11. Click inside the MathScript Node and type the following commands.
x = linspace(0, 6*pi, 100);
b = amp*sin(x);
Notice that the x = linspace(0, 6*pi, 100); command creates a new variable x and populates that variable with 100 samples evenly distributed between 0 and 6*pi.
(Optional) You also can right-click the MathScript Node and select Import from the shortcut menu to import an .m file that you created.
Figure 4. Easily import your custom .m files into the MathScript Node
12. Right-click the left side of MathScript Node frame and select Add Input from the shortcut menu.
Type amp in the input terminal to add an input for the amp variable in the script. This creates an input to the MathScript Node that the Amplitude control terminal can be wired into.
2/6
www.ni.com
Figure 5. Create inputs on the MathScript Node to pass in data using graphical wires.
13. Right-click the right side of the MathScript Node frame and select Add Output sinusoid from the menu. Youll notice that the menu provides all of the declared variables within the
MathScript Node as an option to output. This creates an output from the MathScript Node that can be wired to the Sinusoid indicator terminal.
3/6
www.ni.com
Figure 8. This is the Sine.vi front panel after running the application.
18. Drag the slider of the Amplitude control to a different value and run the VI again. Notice that the sine wave updates accordingly.
19. (Optional) Click the Run Continuously button, or the circular arrows, at the top of the front panel. Notice that the waveform graph updates each time you change the value of the Amplitude
control.
4. Script Highlighting
Script highlighting uses colors to distinguish between different parts of a script in a MathScript Node. These colors improve the readability of the script and help you debug a script that contains
errors or returns unexpected data. For example, you can use script highlighting to see when a user-defined function or a variable overrides a built-in MathScript function. Script highlighting is
enabled by default, except for MathScript Nodes that were last saved in a version of LabVIEW prior to LabVIEW 8.5, and uses custom colors.
To disable script highlighting, right-click inside a MathScript Node and select Script Highlighting None. To enable script highlighting, there are two options: syntax highlighting and data type
highlighting.
Syntax Highlighting
Syntax highlighting displays script elements such as operators and comments in different colors. For example, if a variable or user-defined function overrides a built-in MathScript function, syntax
highlighting colors that script element as a variable or user-defined function. You can customize the script highlighting colors for nodes in which it is enabled by using the Syntax section of the
MathScript page of the Options dialog box:
Figure 9. Customize syntax highlighting colors by using the MathScript category in the Options menu.
To enable syntax highlighting, right-click inside a node and choose Script Highlighting Syntax.
4/6
www.ni.com
Figure 10. Customize data types highlighting colors by using the MathScript category in the Options menu.
To enable data type highlighting, right-click inside a node and choose Script Highlighting Data Types.
Figure 11. Use the MathScript probe to view intermittent script values when debugging your .m file code.
5/6
www.ni.com
Execution highlighting
The gray region on the left side of the MathScript Node, used to interact with these tools, displays the following:
Red error glyphs next to lines of the script that contain an error
Warning glyphs
Breakpoints
Figure 12. The gray region on the left side of the MathScript Node is used for debugging techniques such as setting breakpoints.
Just like breakpoints in graphical code, the block diagram brings the specific line of code where the breakpoint exists into key focus, and the VI pauses. You can then execute single stepping and
execution highlighting using the appropriate buttons on the LabVIEW toolbar. The error list window also lists the lines of code where an error exists. When you select the error within this window
and click the Show Error button, LabVIEW highlights the line of script that contains the error.
Figure 13. A warning glyph appears next to lines containing function calls that cause the MathScript Engine to execute with slower run-time performance.
The warning glyph indicates that LabVIEW operates with reduced error checking and slower run-time performance for the MathScript Node. To improve the error checking and optimize the
performance of the MathScript Node, remove this function from scripts and user-defined functions. Also, do not change the MathScript search path list at run time. Instead, use the MathScript
Options page to configure the default search path list for MathScript Nodes in the main application.
6/6
www.ni.com