필터 지우기
필터 지우기

Plotting two surfaces in cylindrical coordinates

조회 수: 1 (최근 30일)
Thanos Pol
Thanos Pol 2022년 10월 7일
댓글: Gautam Chettiar 2022년 10월 7일
Hello,
I need to plot the following surfaces given by:
,
where ρ is the radius, z is the height and ϕthe azimuth. are constants with .
The first surface denotes a torus.

답변 (1개)

Gautam Chettiar
Gautam Chettiar 2022년 10월 7일
theta = linspace(0, 10 * pi);
z = linspace(0, 5);
[Theta, Z] = meshgrid(theta, z);
% Set the constants
% c >= a
a = 5;
c = 10;
r = sqrt(c ^ 2 - a ^ 2 - z .^ 2) + c;
[x, y, z] = pol2cart(Theta, r, Z);
mesh(x, y, z);
axis equal
  댓글 수: 2
Thanos Pol
Thanos Pol 2022년 10월 7일
So to print the second surface, I should do the something like the following?(which produces an error)
r=sqrt(tan(theta)*2*a.*z-z.^2+a^2);
[x, y, z] = pol2cart(Theta, r, Z);
mesh(x, y, z);
Gautam Chettiar
Gautam Chettiar 2022년 10월 7일
I implemented it, but I faced the complex datatype issue, so I used abs() to fix it, if its wrong then please choose appropriate parameters for the same:
clc
clear all
close all
theta = linspace(0, 2 * pi);
z = linspace(0, 5);
[Theta, Z] = meshgrid(theta, z);
% Set the constants
% c >= a
a = 10;
c = 10;
phi0 = 0;
r = abs(sqrt(2 * a * z .* tan(theta - phi0) - z .^ 2 + a ^ 2)) ;
[x, y, z] = pol2cart(Theta, r, Z);
mesh(x, y, z);
axis equal

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by