Cos^2(2theta) 3d polar graph in MATLAB

How do i graph cos^2(2theta) in 3d ploar grpah? in MATLAB
Cos^2(2theta) where 0=<theta=<90 and 0=<phi=<360

5 comentarios

John D'Errico
John D'Errico el 14 de Sept. de 2021
This is a function of ONE variable, as far as you have said. The cosine function returns a single value for any input.
How do you expect to plot that in THREE dimensions? What do you want to see?
Tracy Colbert
Tracy Colbert el 14 de Sept. de 2021
cos^2(2theta) where 0<= theta<=90 and 0<=phi<=360, im sorry im new to MATLAB
Star Strider
Star Strider el 14 de Sept. de 2021
What’s phi?
Tracy Colbert
Tracy Colbert el 14 de Sept. de 2021
Literally this is all ive been given, i know it is supposed to look like a dome
David Goodmanson
David Goodmanson el 14 de Sept. de 2021
Editada: David Goodmanson el 16 de Sept. de 2021
Hello Tracy,
Assume that theta and phi have the usual convention for spherical coordinates,
x = r*sin(theta)*cos(phi) y = r*sin(theta)*sin(phi) z = r*cos(theta)
Then if the intent is r = constant, and new z = f(theta), it seems more likely that the function would be cos^2(theta). This will give something that is axially symmetric around the z axis and looks like the end of a football. But If the intent is r = f(theta) and z defined in the usual way, then cos^2(2*theta) works but does not look like a dome. Does any of the material you have mention the meshgrid function, or plotting using surf?

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 15 de Sept. de 2021
Editada: Walter Roberson el 15 de Sept. de 2021
%0=<theta=<90 and 0=<phi=<360
[Theta, Phi] = meshgrid(linspace(0,90,361), linspace(0,360,361));
%cos^2(2theta)
R = cosd(2*Theta).^2;
[X, Y, Z] = sph2cart(Theta, Phi, R);
surf(X, Y, Z, 'edgecolor', 'none')
xlabel('X'); ylabel('Y')

2 comentarios

Tracy Colbert
Tracy Colbert el 15 de Sept. de 2021
Thank you very much!!!
I forgot to account for degrees.
%0=<theta=<90 and 0=<phi=<360
[Theta, Phi] = meshgrid(linspace(0,90,361), linspace(0,360,361));
%cos^2(2theta)
R = cosd(2*Theta).^2;
[X, Y, Z] = sph2cart(Theta*pi/180, Phi*pi/180, R);
surf(X, Y, Z, 'edgecolor', 'none')
xlabel('X'); ylabel('Y')

Iniciar sesión para comentar.

% Define theta and r vectors
theta = linspace(0, 2*pi, 360);
r = cos(2*theta).^2;
% Convert polar coordinates to Cartesian coordinates
x = r.*cos(theta);
y = r.*sin(theta);
z = r;
% Plot 3D polar graph
plot3(x, y, z)
title('3D Polar Graph of cos^2(2\theta)')
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')

Categorías

Más información sobre Polar Plots en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 14 de Sept. de 2021

Respondida:

el 9 de Mzo. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by