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

Answers (2)

Star Strider
Star Strider on 26 Jul 2015
Edited: Star Strider on 27 Jul 2015
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)')
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.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Asked:

on 26 Jul 2015

Edited:

on 27 Jul 2015

Community Treasure Hunt

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

Start Hunting!