필터 지우기
필터 지우기

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

조회 수: 13 (최근 30일)
Tracy Colbert
Tracy Colbert 2021년 9월 14일
답변: Harshvardhan 2023년 3월 9일
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
Tracy Colbert
Tracy Colbert 2021년 9월 14일
Literally this is all ive been given, i know it is supposed to look like a dome
David Goodmanson
David Goodmanson 2021년 9월 14일
편집: David Goodmanson 2021년 9월 16일
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?

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

답변 (2개)

Walter Roberson
Walter Roberson 2021년 9월 15일
편집: Walter Roberson 2021년 9월 15일
%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
Tracy Colbert
Tracy Colbert 2021년 9월 15일
Thank you very much!!!
Walter Roberson
Walter Roberson 2021년 9월 16일
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')

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


Harshvardhan
Harshvardhan 2023년 3월 9일
% 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')

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by