How to 3D plot equations?

29 ビュー (過去 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 Center および File Exchange2-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