Reputation: 317
I am trying to draw a line at z=0.5 for the following surf
plot. The code is simple enough but now I want to include a line in the surf
plot at 0.5 for example. My parameters are Xq
, Yq
and Vq
, which I input into the surf
command of MATLAB. Xq
, Yq
and Vq
are all 2001x4001 matrices produced by meshgrid
. I find the points in Vq
equal to 0.5 given a particular tolerance, and I get out of the find
command with and x and y coordinate, but I am lost from here on out.
What is the best way to accomplish this?
Upvotes: 1
Views: 1075
Reputation: 65460
You can use contour3
to draw a line where your surface is equal to 0.5. You can specify that you want the 3D line where Vq
is 0.5 by using the fourth input argument.
% Load in some sample data
[Xq, Yq, Vq] = peaks();
% Plot your surface
surf(Xq, Yq, Vq, 'EdgeColor', 'none');
hold on
% Now plot the 3D contour
contour3(Xq, Yq, Vq, [0.5 0.5], 'k');
If you want to get the Xq
and Yq
values that are associated with that contour, you can call contour3
with an output which will return a ContourMatrix
associated with the contour
values = contour3(Xq, Yq, Vq, [0.5 0.5], 'k');
Upvotes: 2