plot 3d curve with conditions
Afficher commentaires plus anciens
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
Réponses (2)
Star Strider
le 26 Juil 2015
Modifié(e) : Star Strider
le 27 Juil 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)')
John D'Errico
le 26 Juil 2015
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.
Catégories
En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!