JCB30304 Data Acquisition System: Chapter 2: Basic Programming Miss Nur Fazira Haris
JCB30304 Data Acquisition System: Chapter 2: Basic Programming Miss Nur Fazira Haris
JCB30304 Data Acquisition System: Chapter 2: Basic Programming Miss Nur Fazira Haris
JCB30304
DATA ACQUISITION SYSTEM
CHAPTER 2 : BASIC PROGRAMMING
MISS NUR FAZIRA HARIS
CHAPTER 2
MATLAB Script
MathScript
The “LabVIEW MathScript Window” is an interactive interface in which you
can enter .m file script commands and see immediate results, variables and
commands history. The window includes a command-line interface where
you can enter commands one-by-one for quick calculations, script
debugging or learning. Alternatively, you can enter and execute groups of
commands through a script editor window.
You can use the “LabVIEW MathScript Window” to enter commands one at
time. You also can enter batch scripts in a simple text editor window, loaded
from a text file, or imported from a separate text editor. The “LabVIEW
MathScript Window” provides immediate feedback in a variety of forms,
such as graphs and text.
LabVIEW MathScript
Combine textual math
and graphical
programming
Reuse many of your m-
file scripts created with
The MathWorks, Inc.
MATLAB® software
What Is LabVIEW MathScript?
Powerful textual programming for
signal processing, analysis, and math
More than 650 built-in functions
Reuse many of your m-file scripts created
with The MathWorks, Inc. MATLAB® and others
Based on original math from NI MATRIXx
Powerful Textual Math Over 650 built-in functions for math, signal processing and analysis
Compatible Generally compatible with the widely used m-file script syntax
Part of LabVIEW Does not require third-party software to compile and execute
Programmatic LabVIEW
Combine graphical & textual code programming
Interface
MathScript Details
Part of the Full, Professional, Student and Evaluation
editions of LabVIEW, for Windows platforms only
(no Linux, Mac, RT, etc.)
MathScript is NOT a standalone replacement for
alternative technical computing software
Third
party toolboxes are not supported
Some commands and variable types are not supported
How do I use Mathscript?
MathScript can be used in two ways
Workspace
Selected Variable
Command Window
Getting Started
Window
The MathScript Window : Variable View
The MathScript Window : Script Tab
Interactively develop and
test scripts and functions Right Click
Pop-up
with the Script Editor Menu
Enter / Edit script text
Save & Compile / Save /
Load / Run scripts
Launch separate Script
Editor window for easy
editing
The MathScript Window : History Tab
Right Click to
Clear History
Exercise 1
In the MathScript window,
Create an array 𝑎 = 1,2,3,4,5.
3 9
Define the matrix .
6 −5
Exercise 2
Given the vector:
>>x=[1 2 5 6 8 9 3]
→ Find the mean value of the vector x.
→ Find the minimum value of the vector x.
→ Find the maximum value of the vector x.
Example: Plotting
Function plot can be used to produce a graph from
two vectors x and y.
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y)
Exercise
Exercise: Plotting
MathScript Node
Embed MathScripts into LabVIEW code
on the block diagram
Populate with m-file script text
Type m-file scripts directly into the node
Import from files
Create inputs/outputs on node edges
MathScript
MathScript compiles script when run Node
Unlike MATLAB® script nodes, MathScript
script nodes do not require third-party
software
MathScript Node
m-Script
MathScript
Node
Right-Click Menu
Programmatic Math with the MathScript
Node
Combine graphical system design with textual math
Deploy with LabVIEW graphical programming
Implement equations and algorithms with text
Goal: Multiple Programming Approaches
Add interactive user interfaces to your Integrate math with real-world I/O and
algorithms instrument control
LabVIEW Mathscript
A LabVIEW tool for executing textual mathematical commands
A B ln R Cln R
3
Creating a LabVIEW MathScript
THANK YOU