How to 3D plot equations?

25 Ansichten (letzte 30 Tage)
Mickell Sherron
Mickell Sherron am 16 Apr. 2018
Beantwortet: Ameer Hamza am 19 Mai 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

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 19 Mai 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);

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by