how to plot z=9-sqrt(x^2+y^2) inside the cylinder r=2?

3 ビュー (過去 30 日間)
Carter Pennington
Carter Pennington 2018 年 12 月 4 日
コメント済み: Carter Pennington 2018 年 12 月 4 日
clear all;
syms x y;
xlabel('x');
ylabel('y');
zlabel('z');
[x,y] = meshgrid(-10:1:10,-10:1:10);
y=9-sqrt(x.^2+y.^2);
surf(x,y,x);
view([10 10 10]);
  1 件のコメント
madhan ravi
madhan ravi 2018 年 12 月 4 日
Use one approach either symbolic or numerical don't mix them together.

サインインしてコメントする。

回答 (2 件)

madhan ravi
madhan ravi 2018 年 12 月 4 日
編集済み: madhan ravi 2018 年 12 月 4 日
syms x y
ezsurf(9-sqrt(x.^2+y.^2));
axis([-10 10 -10 10 -10 10]) % you can limit the range here
hold on
fimplicit3(x^2+y^2==2^2)
view([10 10 10]);
  1 件のコメント
Carter Pennington
Carter Pennington 2018 年 12 月 4 日
wait it needs to be in spherical form

サインインしてコメントする。


KSSV
KSSV 2018 年 12 月 4 日
編集済み: KSSV 2018 年 12 月 4 日
% Mesh a cylinder
R = 2 ; % radius
h = 2. ; % height
m = 50 ;
n = 50 ;
% Discretizing the Height and Angle of the cylinder
nH = linspace(0,h,m) ;
nT = linspace(0,360.,n)*pi/180 ;
[H, T] = meshgrid(nH,nT) ;
% Convert grid to cylindrical coordintes
X = R*cos(T);
Y = R*sin(T);
Z = H ;
%
[x,y] = meshgrid(-R:0.1:R,-R:0.1:R);
z=h-sqrt(x.^2+y.^2);
surf(x,y,z);
hold on
surf(X,Y,Z)
xlabel('x');
ylabel('y');
zlabel('z');
view([10 10 10]);
YOu have to play with the second equation, so that it lies inside cylinder.

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by