How to 3D plot equations?

25 views (last 30 days)
Mickell Sherron
Mickell Sherron on 16 Apr 2018
Answered: Ameer Hamza on 19 May 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

Accepted Answer

Ameer Hamza
Ameer Hamza on 19 May 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);

More Answers (0)

Categories

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

Community Treasure Hunt

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

Start Hunting!