Main Content

surfht

Interactive contour plot

Description

surfht(z) creates an interactive contour plot of the data in matrix z. surfht treats the values in z as the height above the plane.

surfht(x,y,z) creates an interactive contour plot of the data in matrix z, using the x-axis values contained in x and the y-axis values contained in y.

example

Examples

collapse all

This example shows how to use surfht to create an interactive contour plot.

Create a grid of the (x,y) domain from (–2,–2) to (2,2) using meshgrid.

[x,y] = meshgrid(-2:0.2:2,-2:0.2:2);

Evaluate the function z(x,y)=xe(-x2-y2) over this domain.

z = x.*exp(-x.^2 - y.^2);

Open an interactive contour plot. Because meshgrid creates a grid of the x and y values, open the plot using the first row of x and the first column of y.

surfht(x(1,:),y(:,1),z)

Figure contains an axes object and other objects of type uicontrol. The axes object contains 21 objects of type contour, line, text.

The figure shows a contour plot of the z values along the specified x- and y-axes.

Click the plot to evaluate z at the (x,y) coordinates indicated by the intersecting lines.

Interactive contour plot with z evaluated at the x and y coordinates

For example, at x = 0.71041 and y = 0.025723, the value of z is 0.41827.

Alternatively, enter values in the fields labeled X Value and Y Value to evaluate z at the specified coordinates. For example, evaluate z at x = 0.5 and y = 1.

Interactive contour plot with values entered for x and y

The value of z is 0.1397.

Input Arguments

collapse all

z-axis values for contour plot, specified as a numeric matrix.

surfht treats the values in z as the height above the plane. By default, the x-axis values of the plot are the column indices of z, and the y-axis values of the plot are the row indices of z. To change the x- and y-axis values, specify x and y, respectively.

Data Types: single | double

x-axis values for contour plot, specified as a numeric vector. The length of x must match the number of columns in z.

Data Types: single | double

y-axis values for contour plot, specified as a numeric vector. The length of y must match the number of rows in z.

Data Types: single | double

Tips

  • The intersection of the vertical and horizontal reference lines on the interactive plot defines the current x value and y value.

  • Drag the reference lines to watch the interpolated z value (at the top of the plot) update simultaneously.

  • Alternatively, obtain a specific interpolated z value by typing the x value and y value into editable text fields on the x-axis and y-axis, respectively.

Version History

Introduced before R2006a

expand all