Why is the "int" function not evaluating my integral? The "r" variable still has the "int" in it.
clear
clc
theta_s = 0:0.5:pi/2;
syms theta_v phi
for i = 1:length(theta_s)
integ2(i) = ((((1/(2*pi))*((pi-phi)*cos(phi) + sin(phi))*tan(theta_s(i))*tan(theta_v)-(1/pi)*(tan(theta_s(i))+tan(theta_v)+sqrt(tan(theta_v)^2 + tan(theta_s(i))^2 - 2*tan(theta_s(i))*tan(theta_v)*cos(phi)))))*cos(theta_v)*sin(theta_v));
r(i)= int((integ2(i)), theta_v, [0 pi/2]);
end

댓글 수: 1

What reason do you have to lead you to expect that there is a closed form integral?

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

 채택된 답변

David Hill
David Hill 2022년 3월 3일

0 개 추천

theta_s = 0:0.5:pi/2;
syms theta_v
phi=pi/6;%choose a phi or loop for various values of phi
for i = 1:length(theta_s)
integ2(i) = ((((1/(2*pi))*((pi-phi)*cos(phi) + sin(phi))*tan(theta_s(i))*tan(theta_v)-(1/pi)*(tan(theta_s(i))+tan(theta_v)+sqrt(tan(theta_v)^2 + tan(theta_s(i))^2 - 2*tan(theta_s(i))*tan(theta_v)*cos(phi)))))*cos(theta_v)*sin(theta_v));
r(i)= vpaintegral((integ2(i)), theta_v, [0 pi/2]);
end

댓글 수: 6

But I need an answer in terms of phi
Torsten
Torsten 2022년 3월 3일
If "int" does not return an analytical expression for the integral in terms of phi, you'll have to be satisfied with an evaluation for different numerical values of phi.
AndresVar
AndresVar 2022년 3월 4일
@Ali Almakhmari the square root part is too complicated to find a simplified closed form. Could there be a typo or maybe use some identity to simplify?
Actually I forgot to say this, but after integrating this function in terms of theta_v, I will do another integration in terms of phi from 0 to pi, so am not looking for a symbolic answer at the end if that helps. I just don't how to do it because matlab is not evaulating it even with two int functions (for theta_v and phi)
Works fine.
theta_s = 0:0.5:pi/2;
syms theta_v phi
for i = 1:length(theta_s)
integ2(i) = ((((1/(2*pi))*((pi-phi)*cos(phi) + sin(phi))*tan(theta_s(i))*tan(theta_v)-(1/pi)*(tan(theta_s(i))+tan(theta_v)+sqrt(tan(theta_v)^2 + tan(theta_s(i))^2 - 2*tan(theta_s(i))*tan(theta_v)*cos(phi)))))*cos(theta_v)*sin(theta_v));
r(i)= vpaintegral(vpaintegral((integ2(i)), theta_v, [0 pi/2]),phi,[0 pi]);
end
By the way, integrating first with respect to phi is faster.
At one point I saw a closed form solution for integration with respect to phi, but I was not able to reproduce that later.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2022년 3월 3일

댓글:

2022년 3월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by