# 2.1 Lab 2: labview mathscript and hybrid programming  (Page 3/6)

 Page 3 / 6

break;

end

end

LabVIEW MathScript supports the relational and logical operators listed below.

Relational Operators

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

Logical Operators

 Symbol Meaning & AND $\mid$ 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.

## 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.

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

so some one know about replacing silicon atom with phosphorous in semiconductors device?
how to fabricate graphene ink ?
for screen printed electrodes ?
SUYASH
What is lattice structure?
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
what's the easiest and fastest way to the synthesize AgNP?
China
Cied
types of nano material
I start with an easy one. carbon nanotubes woven into a long filament like a string
Porter
many many of nanotubes
Porter
what is the k.e before it land
Yasmin
what is the function of carbon nanotubes?
Cesar
I'm interested in nanotube
Uday
what is nanomaterials​ and their applications of sensors.
what is nano technology
what is system testing?
preparation of nanomaterial
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
what is system testing
what is the application of nanotechnology?
Stotaw
In this morden time nanotechnology used in many field . 1-Electronics-manufacturad IC ,RAM,MRAM,solar panel etc 2-Helth and Medical-Nanomedicine,Drug Dilivery for cancer treatment etc 3- Atomobile -MEMS, Coating on car etc. and may other field for details you can check at Google
Azam
anybody can imagine what will be happen after 100 years from now in nano tech world
Prasenjit
after 100 year this will be not nanotechnology maybe this technology name will be change . maybe aftet 100 year . we work on electron lable practically about its properties and behaviour by the different instruments
Azam
name doesn't matter , whatever it will be change... I'm taking about effect on circumstances of the microscopic world
Prasenjit
how hard could it be to apply nanotechnology against viral infections such HIV or Ebola?
Damian
silver nanoparticles could handle the job?
Damian
not now but maybe in future only AgNP maybe any other nanomaterials
Azam
Hello
Uday
I'm interested in Nanotube
Uday
this technology will not going on for the long time , so I'm thinking about femtotechnology 10^-15
Prasenjit
can nanotechnology change the direction of the face of the world
At high concentrations (>0.01 M), the relation between absorptivity coefficient and absorbance is no longer linear. This is due to the electrostatic interactions between the quantum dots in close proximity. If the concentration of the solution is high, another effect that is seen is the scattering of light from the large number of quantum dots. This assumption only works at low concentrations of the analyte. Presence of stray light.
the Beer law works very well for dilute solutions but fails for very high concentrations. why?
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!