Graphics Programs Reference
In-Depth Information
maximum two digits.
labels = num2str(data(:,3),2);
The 2D plot of our data is generated in two steps. Firstly, the data are dis-
played as empty circles by using the
plot
command. Secondly, the data
are labeled by using the function
text(x,y,'string')
which adds text
contained in
string
to the
xy
location
.
The value 1 is added to all
x
coor-
dinates as a small offset between the circles and the text.
plot(data(:,1),data(:,2),'o')
hold on
text(data(:,1)+1,data(:,2),labels);
hold off
This plot helps us to defi ne the axis limits for gridding and contouring,
xlim
= [420 470] and
ylim
= [70 120]. The function
meshgrid
transforms
the domain specifi ed by vectors
x
and
y
into arrays
XI
and
YI
. The rows of
the output array
XI
are copies of the vector
x
and the columns of the output
array
YI
are copies of the vector
y
. We choose 1.0 as grid intervals.
x = 420:1:470; y = 70:1:120;
[XI,YI] = meshgrid(x,y);
The biharmonic spline interpolation is used to interpolate the irregular-
spaced data at the grid points specifi ed by
XI
and
YI
.
ZI = griddata(data(:,1),data(:,2),data(:,3),XI,YI,'v4');
The option
v4
depicts the biharmonic spline interpolation, which was the
sole gridding algorithm until MATLAB4 was replaced by MATLAB5.
MATLAB provides various tools for the visualization of the results. The
simplest way to display the gridding results is a contour plot using
con-
tour
. By default, the number of contour levels and the values of the contour
levels are chosen automatically depending on the minimum and maximum
values of
z
.
contour(XI,YI,ZI)
Alternatively, the number of contours can be chosen manually, e.g., 10 con-
tour levels.
contour(XI,YI,ZI,10)
Contouring can also be performed at values specifi ed in a vector
v
. Since the
maximum and minimum values of
z
is