How to 3D plot equations?

26 visualizaciones (últimos 30 días)
Mickell Sherron
Mickell Sherron el 16 de Abr. de 2018
Respondida: Ameer Hamza el 19 de Mayo de 2018
Hi everyone !!! I attempted to plot the following equations, but I am having trouble doing so. Do you think you can help? Thanks.
x^2/9+y^2/16+z^2/9=1 y=5 y^2+z^2=9

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 19 de Mayo de 2018
You can plot them separately using the following code
x = -5:0.1:5;
y = -5:0.1:5;
z = -5:0.1:5;
[X, Y] = meshgrid(x, y);
Z = 3*sqrt(1-X.^2/9-Y.^2/16);
Z(imag(Z)~=0) = inf;
surf(X, Y, Z);
[X, Z] = meshgrid(x, z);
Y = 5*ones(size(X));
figure;
surf(X, Y, Z);
[X, Y] = meshgrid(x, y);
Z = sqrt(9-Y.^2);
Z(imag(Z)~=0) = inf;
figure;
surf(X, Y, Z);
Or you can plot them together using this code
x = -5:0.1:5;
y = -5:0.1:5;
z = -3:0.1:3;
[X, Y] = meshgrid(x, y);
Z = 3*sqrt(1-X.^2/9-Y.^2/16);
Z(imag(Z)~=0) = inf;
surf(X, Y, Z);
hold on
[X, Z] = meshgrid(x, z);
Y = 5*ones(size(X));
% figure;
surf(X, Y, Z);
[X, Y] = meshgrid(x, y);
Z = sqrt(9-Y.^2);
Z(imag(Z)~=0) = inf;
% figure;
surf(X, Y, Z);

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by