National Instruments LabView Label Maker User Manual


 
Chapter 2 New Features in LabVIEW 5.1
LabVIEW 5.1 Addendum 2-18
©
National Instruments Corporation
Creating a MATLAB Script
Complete the following instructions to create and run a VI that uses a
MATLAB script.
1. From the block diagram, choose Functions»Mathematics»
Formula»MATLAB Script. Place the node on the block diagram, and
size it according to the amount of script you want to include in the
window. The MATLAB script node appears as shown below.
2. With the operating tool, enter the script in the MATLAB script node.
For example, the following simple MATLAB script creates a matrix of
random values, plots that information to a graph, and displays the
matrix in MATLAB.
a=rand(50)
surf(a)
3. To add inputs and outputs for variables, right-click the right side of the
node frame and select Add Input or Add Output. Type in
a to add an
output for the a variable that is included in your MATLAB script. By
default your node already includes one input and one output terminal
for the error in and error out parameters.
4. Verify the datatype of the inputs and/or outputs. The error-checking
input and output are already the correct datatype. In MATLAB, the
default datatype for any new input or output is Real. Right-click the a
output and select Choose Type. From the submenu that appears, select
an available datatype: Real, Complex, Real Vector, Complex Vector,
Real Matrix, or Complex Matrix. For the a output, choose Real
Matrix.
5. Create controls and indicators for each input and output. Right-click
the a output terminal and select Create Indicator. Right-click the
error out output terminal and select Create Indicator. Indicators for
a and error out appear on the front panel and terminals appear wired
to these outputs on the block diagram.
6. Go to the front panel. Resize your a indicator so you can see the
generated numbers when you run the VI.