필터 지우기
필터 지우기

extracting a 2d plane from a 3d surface plot

조회 수: 5 (최근 30일)
Paul B
Paul B 2012년 4월 21일
Hi guys, sorry if this is an easy question but I'm new to matlab. I've done a surface plot with two 3-d planes in it. I have vectors x.dat and y.dat, and the 2 by 2 matrices z1.dat and z2.dat. I can plot both of these surfaces on one figure by
load x.dat
load y.dat
load z1.dat
load z2.dat
hold on;
surf(x,y,z1,'FaceColor',[1 0 0],...
'EdgeColor',[1 0 0]);
surf(x,y,z2,'FaceColor',[0 0 1],...
'EdgeColor',[0 0 1]);
hold off;
This plots z1 and z2 nicely in 3d space with one of them blue and the other red. What I'd like to do is plot the plane z=0, to show the intersection of z1 and z2 in the x-y plane at z=0. Is this possible to do with matlab? Thanks in advance for any suggestions.

채택된 답변

Richard Brown
Richard Brown 2012년 4월 21일
How about
contour(x, y, z1-z2, [0 0])
?
  댓글 수: 2
Paul B
Paul B 2012년 4월 21일
Ah ok! I'm such a newb I didn't know about that command. Actually this didn't quite work, it only plotted the zeros of z2, but
hold on;
contour(x, y, z1, [0 0],'EdgeColor',[1 0 0]);
contour(x, y, z2, [0 0],'EdgeColor',[0 0 1]);
hold off
does exactly what I wanted. Thanks for your help! It looks great :P
Richard Brown
Richard Brown 2012년 4월 21일
Cool, sorry -- I read your question a bit fast! Glad you got it sorted

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Richard Brown
Richard Brown 2012년 4월 21일
Plotting the plane is pretty easy
surf(x, y, zeros(size(x))
You can adjust colour, edgecolor, transparency etc if you want. Is that what you were after?
  댓글 수: 1
Paul B
Paul B 2012년 4월 21일
Sorry, not really! The data x and y are just linearly spaced, ie. [x]=[1,2,...N], [y]=[1,2,...N], and the matrices z1 and z2 contain all the function information. So if I plot what you suggested, all I get is the flat plane z=0, which is not what I'm after; probably due to my poor explanation!
Basically there are certain x,y values which give z1=z2=0. I want to plot those values in the x-y plane. You can kind of see it if you set (using axis properties) a very small range like z=-0.01 to z=0.01 and then view from a birdseye perspective. But I was wondering if there's a way to extract the x-y plane for some value of z.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by