plot 3d curve with conditions

Hi everyone,
I would like to plot a 3D curve in the form of y=f(x,y) with two conditions on x and y ( x>2*y and y<100-x/2)
Can someone help me to code it?
Thank you

답변 (2개)

Star Strider
Star Strider 2015년 7월 26일
편집: Star Strider 2015년 7월 27일

1 개 추천

Not certain what you want, but this seems to work:
x = linspace(-9, 9);
y = linspace(-9, 9);
f = @(x,y) x.^2 .* cos(2*pi*y);
[X1,Y1] = meshgrid(x(x<2*y), y);
[X2, Y2] = meshgrid(x, y);
F1 = f(X1, Y1);
F2 = f(X2,Y2);
figure(1)
mesh(X1, Y1, F1)
grid on
xlabel('x')
ylabel('y')
title('f(x>2\cdoty,y)')
figure(2)
mesh(X2, Y2, F2)
grid on
xlabel('x')
ylabel('y')
title('f(x,y)')
Adding the second constraint:
y = linspace(-9, 9);
f = @(x,y) x.^2 .* cos(2*pi*y);
[X1,Y1] = meshgrid(x(x<2*y), y(y<100-x/2));
[X2, Y2] = meshgrid(x, y);
F1 = f(X1, Y1);
F2 = f(X2,Y2);
figure(1)
mesh(X1, Y1, F1)
grid on
xlabel('x')
ylabel('y')
title('f(x>2\cdoty, y<100\cdotx/2)')
figure(2)
mesh(X2, Y2, F2)
grid on
xlabel('x')
ylabel('y')
title('f(x,y)')
John D'Errico
John D'Errico 2015년 7월 26일

0 개 추천

I would triangulate the domain of interest. Then I would use one of the tools that can build a contour plot from that triangulated domain, where the only contour is at zero, thus
y - f(x,y) == 0
There are several tricontour tools on the file exchange.
The fact is though, this is not a 3-d curve,and your question explicitly states that as a goal. So I'm not sure what your goal really is.

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2015년 7월 26일

편집:

2015년 7월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by