How to 3D plot equations?

조회 수: 25 (최근 30일)
Mickell Sherron
Mickell Sherron 2018년 4월 16일
답변: Ameer Hamza 2018년 5월 19일
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

채택된 답변

Ameer Hamza
Ameer Hamza 2018년 5월 19일
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);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by