# 1.3 Graphical representation of data in labview mathscript

 Page 1 / 1
Introduces graphical representation of data in LabVIEW MathScript.

## Graphical representation of data in labview mathscript

LABVIEW MATHSCRIPT provides a great variety of functions and techniques for graphical display of data. The flexibility andease of use of LABVIEW MATHSCRIPT's plotting tools is one of its key strengths. In LABVIEW MATHSCRIPT graphs are shown in a figure window. Several figurewindows can be displayed simultaneously, but only one is active. All graphing commands are applied to the active figure. The command `figure(n)` will activate figure number `n` or create a new figure indexed by `n` .

## Tools for plotting

In this section we present some of the most commonly used functions for plotting in LABVIEW MATHSCRIPT.

• `plot` - The plot and stem functions can take a large number of arguments, see help plot and help stem. For example theline type and color can easily be changed. `plot(y)` plots the values in vector `y` versus their index. `plot(x,y)` plots the values in vector `y` versus `x` . The `plot` function produces a piecewise linear graph between its data values. With enough data points it lookscontinuous.
• `stem` - Using `stem(y)` the data sequence `y` is plotted as stems from the x-axis terminated with circles for the data values. `stem` is the natural way of plotting sequences. `stem(x,y)` plots the data sequence `y` at the values specified in `x` .
• `xlabel('string')` - Labels the x-axis with `string` .
• `ylabel('string')` - Labels the y-axis with `string` .
• `title('string')` - Gives the plot the title `string` .

To illustrate this consider the following example.

In this example we plot the function y = x2 for x 2 [-2; 2].

`x = -2:0.2:2;`

`y = x.^2;`

`figure(1);`

`plot(x,y);`

`xlabel('x');`

`ylabel('y=x^2');`

`title('Simple plot');`

`figure(2);`

`stem(x,y);`

`xlabel('x');`

`ylabel('y=x^2');`

`title('Simple stem plot');`

This code produces the following two figures.

Some more commands that can be helpful when working with plots:

• hold on / off - Normally hold is off. This means that the plot command replaces the current plot with the new one. To add anew plot to an existing graph use `hold on` . If you want to overwrite the current plot again, use `hold off` .
• `legend('plot1','plot2',...,'plot N')` - The `legend` command provides an easy way to identify individual plots when there are more than one per figure. A legendbox will be added with strings matched to the plots.
• `axis([xmin xmax ymin ymax])` - Use the `axis` command to set the axis as you wish. Use `axis on/off` to toggle the axis on and off respectively.
• `subplot(m,n,p)` -Divides the figure window into `m` rows, `n` columns and selects the `p` p'th subplot as the current plot, e.g `subplot(2,1,1)` divides the figure in two and selects the upper part. `subplot(2,1,2)` selects the lower part.
• `grid on/off` - This command adds or removes a rectangular grid to your plot.

This example illustrates `hold` , `legend` and `axis` .

`x = -3:0.1:3; y1 = -x.^2; y2 = x.^2;`

`figure(1);`

`plot(x,y1);`

`hold on;`

`plot(x,y2,'--');`

`hold off;`

`xlabel('x');`

`ylabel('y_1=-x^2 and y_2=x^2');`

`legend('y_1=-x^2','y_2=x^2');`

`figure(2);`

`plot(x,y1);`

`hold on;`

`plot(x,y2,'--');`

`hold off;`

`xlabel('x');`

`ylabel('y_1=-x^2 and y_2=x^2');`

`legend('y_1=-x^2','y_2=x^2');`

`axis([-1 1 -10 10]);`

The result is shown below.

In this example we illustrate subplot and grid.

`x = -3:0.2:3; y1 = -x.^2; y2 = x.^2;`

`subplot(2,1,1);`

`plot(x,y1);`

`xlabel('x'); ylabel('y_1=-x^2');`

`grid on;`

`subplot(2,1,2);`

`plot(x,y2);`

`xlabel('x');`

`ylabel('y_2=x^2');`

Now, the result is shown below.

## Printing and exporting graphics

After you have created your figures you may want to print them or export them to graphic files. In the "File"menu use "Print" to print the figure or "Save As" to save your figure to one of the many available graphics formats. Using theseoptions should be sufficient in most cases, but there are also a large number of adjustments available by using "Export setup","Page Setup" and "Print Setup".

## 3d graphics

We end this module on graphics with a sneak peek into 3D plots. The new functions here are `meshgrid` and `mesh` . In the example below we see that `meshgrid` produces `x` and `y` vectors suitable for 3D plotting and that `mesh(x,y,z)` plots `z` as a function of both `x` and `y` .

Example: Creating our first 3D plot.

`[x,y] = meshgrid(-3:.1:3);`

`z = x.^2+y.^2;`

`mesh(x,y,z);`

`xlabel('x');`

`ylabel('y');`

`zlabel('z=x^2+y^2');`

This code gives us the following 3D plot.

how can chip be made from sand
are nano particles real
yeah
Joseph
Hello, if I study Physics teacher in bachelor, can I study Nanotechnology in master?
no can't
Lohitha
where we get a research paper on Nano chemistry....?
nanopartical of organic/inorganic / physical chemistry , pdf / thesis / review
Ali
what are the products of Nano chemistry?
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
hey
Giriraj
Preparation and Applications of Nanomaterial for Drug Delivery
revolt
da
Application of nanotechnology in medicine
has a lot of application modern world
Kamaluddeen
yes
narayan
what is variations in raman spectra for nanomaterials
ya I also want to know the raman spectra
Bhagvanji
I only see partial conversation and what's the question here!
what about nanotechnology for water purification
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
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!