Evaluating numerical value of symbolic integral
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Amit Patel
el 25 de En. de 2019
Editada: Amit Patel
el 26 de En. de 2019
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 comentarios
madhan ravi
el 25 de En. de 2019
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
el 25 de En. de 2019
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
Respuesta aceptada
Walter Roberson
el 25 de En. de 2019
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 comentarios
Walter Roberson
el 25 de En. de 2019
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!