Summary: Introduces graphical representation of data in LabVIEW MathScript.
figure(n)will activate figure number
n or create a new figure indexed by
n.plot- The plot and stem functions can take a large
number of arguments, see help plot and help stem. For example the
line type and color can easily be changed.
plot(y) plots the values in vector
yversus their index.
plot(x,y) plots the values in vector
yversus
x. The
plot function produces a piecewise linear graph between
its data values. With enough data points it looks
continuous.stem- Using
stem(y)the data sequence
yis 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.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');
![]() Figure 1: |
![]() Figure 2: |
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 legend
box 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
pp'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.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]);
Figure 3 |
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');
![]() Figure 4: |
meshgrid and
mesh. In the example below we see that
meshgridproduces
xand
yvectors suitable for 3D plotting and that
mesh(x,y,z) plots
z as a function of both
x and
y.[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');![]() Figure 5: |
Comments, questions, feedback, criticisms?
"This course provides a brief introduction to LabVIEW MathScript, the textual math componenet of LabVIEW. The modules for this course include typical syntax and programming methods commonly used […]"