Solving an equation with two different variables of different ranges

조회 수: 1 (최근 30일)
CAAJ
CAAJ 2017년 2월 27일
댓글: CAAJ 2017년 3월 2일
Hello All,
I am looking to solve the equation below with two different variables, phi and theta. However, those two variables are set for different ranges and the matrices sizes are different. Is there a way to get around this and solve for phi first, and then solve provide a results for every theta? Below I will provide the variables and their set ranges along with the equation to solve.
NS=4*2^(1-1);
h=(pi/2-0)/NS;
phi=0:h:pi/2;
theta = 0:2:90;
fphi = @ (phi) 1/sqrt(1-sin(theta/2).^2*sin(phi).^2) %This line may not be written properly as well as the next to account for theta as well. Again I would like to solve for phi, and then theta.
F = fphi(phi);
Any help would be much appreciated!
Thank you!

채택된 답변

KSSV
KSSV 2017년 2월 27일
NS=4*2^(1-1);
h=(pi/2-0)/NS;
Phi=0:h:pi/2;
Theta = 0:2:90;
[phi,theta] = meshgrid(Phi,Theta) ;
Fphi = @ (phi,theta) 1./sqrt(1-sin(theta/2).^2.*sin(phi).^2) ; %This line may not be written properly as well as the next to account for theta as well. Again I would like to solve for phi, and then theta.
F = Fphi(phi,theta);
% fphi = 1./(1-sin(theta/2).^2.*sin(phi).^2).^0.5 ;
surf(Phi,Theta,F)
  댓글 수: 3
Walter Roberson
Walter Roberson 2017년 2월 27일
Plotting the result is not mandatory.
If you do want to plot and prefer a different style of plot, let us know what you were hoping for.
CAAJ
CAAJ 2017년 3월 2일
Thank you very much for your assistance, the function meshgrid worked as needed!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by