How do I plot a graph for ϴ for a given range of independent variables?

1 visualizzazione (ultimi 30 giorni)
Hiya, I am trying to plot a graph (3D surface is ideal) for the dependent variable, ϴ, and independent variables, r and Φ, given the equation as below:
ϴ = 2 * asin((P * H^3 * cos(⁡Φ) / (6 * E * π * r^4 * n * R * sin⁡(Φ)^3 ))
for 0 < ϴ < 30
My aim is to be able to pick a certain value of ϴ, and will be given the value(s) for r and value(s) for Φ, if they are not below the limit (equation for the limit given at the end).
This is the code that I've written as of now:
r=[1.0:-0.05:0.5];
P=1.257*10.^8;
R=8/1000;
H=15/1000;
E=2.7*10.^9;
deg=25;
phi=deg*pi/180;
while deg<=80
deg=deg+0.5
phi=deg*pi/180;
for i = 1:length(r)
theta=(2*asin((P*H.^3*cos(phi))/(6*E*pi*(r(i)/1000).^2*R*(sin(phi)).^3)))*180/pi;
end
end
I would also like to plot another graph within the same plot, which serves as a limit, with this equation:
phi1 = atan(H / (2 * R - 2 * r))
Thanks!

Risposta accettata

Chunru
Chunru il 22 Apr 2022
Modificato: Chunru il 22 Apr 2022
Assume that r, theta, phi are 3d spherical coordinates. theta is elevation and phi is azimuth.
The following is the code to plot the 3d surface of your function. However, you need to check your parameters to ensure that theta is real (or the argument inside asin should be within +/- 1).
r=(1.0:-0.05:0.5)'; % column vector
P=1.257*10.^8;
R=8/1000;
H=15/1000;
E=2.7*10.^9;
phi = deg2rad(25:.5:80); % row vector
% theta as a function of r (along column) and phi (along row)
theta1=(2 * asin((P*H.^3*cos(phi) ) ./ (6*E*pi*(r/1000).^2 * R * sin(phi).^3 )) );
% Remove the complex angle (this may have side effect)
theta = real(theta1);
theta(imag(theta1)~=0) = nan;
% Get the corresponding x-y-z
xx = r .* cos(theta) .* cos(phi);
yy = r .* cos(theta) .* sin(phi);
zz = r .* sin(theta);
surf(xx, yy, zz, 'EdgeColor', 'none')
  3 Commenti
Chunru
Chunru il 25 Apr 2022
Modificato: Chunru il 25 Apr 2022
You want to plot surface of a function by specifying rho, theta, and phi in spherical coordinates. These spherical coordinates can be converted to Cartisian coordinates by those conversion formula (assuming that you have followed the following convention). Then the matlab function surf plot out the 3d surface specified by Cartisian coordinates.
Algorithms
The mapping from spherical coordinates to three-dimensional Cartesian coordinates is
x = r .* cos(elevation) .* cos(azimuth)
y = r .* cos(elevation) .* sin(azimuth)
z = r .* sin(elevation)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by