Evaluating numerical value of symbolic integral

14 次查看(过去 30 天)
I need numerical value of Eb_avg, instead matlab is giving symbolic expression and is not performing the integrals
Following is my code:
clc;
clear all;
close all;
neta=0.75;
rho=0.5;
T=1e-3;
P_No_dB=15;
P_No_end=size(P_No_dB);
in=P_No_end(1,2);
P=10.^(P_No_dB./10);
sigma_sq=1;
Ebmax=100*1e-3;
d0=1;
m=3;
var_hsd=(d0^(-m));
d1=2;
m=3;
var_hse=(d1^(-m));
d2=2;
m=3;
var_hed=(d2^(-m));
R=2;
SNRth=2^R;
count=0;
beta=(2^R-1).*sigma_sq./(P.*(1-rho));
lambda_0=1/(var_hsd);
lambda_1=1/(var_hse);
lambda_2=1/(var_hed);
Eb=[];
for j=1:in
syms x y
fun=(T*lambda_2.*((x-y.*(1-rho))./(y.*(1-rho))).*sigma_sq.*( expint(lambda_2.*(T.*(x-y.*(1-rho)).*sigma_sq)./(y.*(1-rho).*(T.*neta.*rho.*P.*y +Ebmax))) -expint(lambda_2.*((x-y.*(1-rho)).*sigma_sq)./(y.*(1-rho).*(neta.*rho.*P.*y))) ) -T.*neta.*rho.*P.*y.*( exp(-lambda_2.*(T.*(x-y.*(1-rho)).*sigma_sq)./(y.*(1-rho).*(T.*neta.*rho.*P.*y +Ebmax))) - exp(-lambda_2.*((x-y.*(1-rho)).*sigma_sq)./(y.*(1-rho).*(neta.*rho.*P.*y))) )).*lambda_1.*lambda_0.*exp(-lambda_1.*y).*exp(-lambda_0.*x);
fun1=int(fun,y,beta,x/(1-rho));
Eb_avg=int(fun1,x,0,Inf);
Eb=[Eb Eb_avg];
count=count+1
end
  3 个评论
madhan ravi
madhan ravi 2019-1-25
In addition to Torsten's comment aren't you calculating the same thing over and over again? I haven't paid enough attention to details.
Walter Roberson
Walter Roberson 2019-1-25
for j=1:in would normally be doing the same calculations over and over again, but the upper bound happens to be defined as the second dimension of a scalar, so in = 1

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2019-1-25
change both int() into vpaintegral().
You have a function in two variables, and it does not look to have a closed form in either of the two variables individually, so the first int() is going to return unresolved. It looks like MATLAB is not able to find a closed form for the 2D integral. So switch to numeric integration on formulae by using vpaintegral()
Note: make sure you replace both int() calls.
... It still won't be fast. Integrating to infinity seldom is.
  7 个评论
Walter Roberson
Walter Roberson 2019-1-25
One thing I notice is that the integral of y is 3/50*sqrt(10) lower bound, 2*x upper bound, but with x starting from 0, 2*x can be less than 3/50*sqrt(10) so you are doing "backwards" integration for that stretch. I recommend checking that bound as that hints that possibly you are crossing a discontinuity.
Amit  Patel
Amit Patel 2019-1-26
编辑:Amit Patel 2019-1-26
Yes , thanks for pointing out that issue of bound, I have resolved that and now integral is converging.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by