<< Chapter < Page Chapter >> Page >

break;

end

end

LabVIEW MathScript supports the relational and logical operators listed below.

Relational Operators

Relational Operators
Symbol Meaning
<= less than equal
< less than
>= greater than equal
> greater than
== equal
~= not equal

Logical Operators

Logical Operators
Symbol Meaning
& AND
size 12{ \lline } {} OR
~ NOT

Programming in the labview mathscript window

The MathScript feature allows one to include .m files, which can be created using any text editor. To activate the LabVIEW MathScript interactive window, select Tools MathScript Window from the main menu. To open the LabVIEW MathScript text editor, click the Script tab of the LabVIEW MathScript Window (see [link] ). After typing the .m file textual code, save it and click on the Run script button (green arrow) to run it.

For instance, to write a program to compute the average (mean) of a vector x, the program should use as its input the vector x and return the average value. To write this program, follow the steps outlined below.

Type the following in the empty script:

x=1:10

L=length(x);

sum=0;

for j=1:L

sum=sum+x(j);

end

y=sum/L % the average of x

From the Editor pull-down menu, go to File Save Script As and enter average.m for the file name. Then click on the Run script button to run the program. [link] shows the LabVIEW MathScript interactive window after running the program.

LabVIEW MathScript Interactive Window after Running the Program Average

Sound generation

Assuming the computer used has a sound card, one can use the function sound to play back speech or audio files through its speakers. That is, sound(y,FS) sends the signal in a vector y (with sample frequency FS) out to the speaker. Stereo sounds are played on platforms that support them, with y being an N-by-2 matrix.

Try the following code and listen to a 400 Hz tone:

>>t=0:1/8000:1;

>>x=cos(2*pi*400*t);

>>sound(x,8000);

Now generate a noise signal by typing:

>>noise=randn(1,8000); % generate 8000 samples of noise

>>sound(noise,8000);

The function randn generates Gaussian noise with zero mean and unit variance.

Loading and saving data

One can load or store data using the commands load and save. To save the vector x of the above code in the file data.mat , type:

>>save data x

Note that LabVIEW MathScript data files have the extension .mat. To retrieve the data saved, type:

>>load data

The vector x gets loaded in memory. To see memory contents, use the command whos ,

>>whos

Variable Dimension Type x   1x8000 double array

The command whos gives a list of all the variables currently in memory, along with their dimensions. In the above example, x contains 8000 samples.

To clear up memory after loading a file, type clear all when done. This is important because if one does not clear all the variables, one could experience conflicts with other programs using the same variables.

Reading wave and image files

With LabVIEW MathScript, one can read data from different file types (such as .wav, .jpeg and .bmp) and load them in a vector.

To read an audio data file with .wav extension, use the following command:

>>[y Fs]=wavread(‘filename’)

This command reads a wave file specified by the string filename and returns the sampled data in y with the sampling rate of Fs (in hertz).

Questions & Answers

what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, An interactive approach to signals and systems laboratory. OpenStax CNX. Sep 06, 2012 Download for free at http://cnx.org/content/col10667/1.14
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'An interactive approach to signals and systems laboratory' conversation and receive update notifications?

Ask