Plotting two surfaces in cylindrical coordinates
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I need to plot the following surfaces given by:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1148305/image.png)
where ρ is the radius, z is the height and ϕthe azimuth.
are constants with
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1148310/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1148315/image.png)
The first surface denotes a torus.
1 Kommentar
Antworten (1)
Gautam Chettiar
am 7 Okt. 2022
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 Kommentare
Gautam Chettiar
am 7 Okt. 2022
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
Siehe auch
Kategorien
Mehr zu Annotations 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!