Error (Unable to perform assignment because value of type 'sym' is not convertible to 'double'.)

15 views (last 30 days)
Hi everone,
Can anyone help with the code below? I got the error (Unable to perform assignment because value of type 'sym' is not convertible to 'double'.)
% theoretical
clear all; clear; clc;
d0=0;
h_A=40;
% k=0.003;
k=0.07512;
a1 = 8;
b1 = 0.2;
aL = 2; % LOS path loss exponent
aN = 4; % NLOS path loss exponent
betaL = 61.4;
betaN = 72;
CL = 10^(-betaL/10); % LoS path loss
CN = 10^(-betaN/10); % NLoS path loss
beta = 1/141.4; % Parameters of density and size of the blockage
N =10; % Fixed number of UAVs (for BPP)
h=exprnd(1);
rc =500; % Avg. Cell radius in meters for the simulation
L=(3*10^8)^2/(4*pi*1.05*10^12)^2; % Free space path loss constant
GA_dB = 25;
GA = 10^(GA_dB/10);
gA_dB = -10;
gA = 10^(gA_dB/10);
thetaA = 30; % beamwidth of the main lobe at the ABS
Gu_dB = 15;
Gu = 10^(Gu_dB/10);
gu_dB = -10;
gu = 10^(gu_dB/10);
thetau = 30; % beamwidth of the main lobe at the user
W = 100; % BW MHz
Q = 10; % Noise figure
np_dB = -90 +10*10*log10(W) + Q; % noise power dBm
np = 10^(np_dB/10); % noise power in Watt
PA_dBm= 10; % ABS power dBm
PA = 10^(PA_dBm/10); % ABS power in Watt
A= PA * GA * Gu * L *h_A; % Overall signal strength constant
beta = 1/141.4; % parameters of density and size of the blockage
cr = thetaA/360;
ct = thetau/360;
B = [GA*Gu, GA*gu, gu*GA, gA*gu]; % directivity gain of the interfernce link
pa = [cr*ct, cr*(1-ct), (1-cr)*ct, (1-cr)*(1-ct)]; % probablity of the directivity gain of the interfernce link
av = pa./(GA*Gu);
thresh_dB = 0:5:10;
thresh = 10.^(thresh_dB./10);
syms x r w
xm = sqrt((rc - d0)^2 + h_A^2);
xu = sqrt((rc + d0)^2 + h_A^2);
f(x) = piecewise(x >= h_A & x <= xm, (2 * x) / rc^2, x > xm & x <= xu, (2 * x) / ( pi*rc^2) * acos(((x^2)+ d0^2 - rc^2 - h_A^2 ) / (2 * d0 * sqrt(x^2 - h_A^2))),0);
PL(r) = exp(-beta.*r);
PN(r) = 1-PL(r);
PL(x) = exp(-beta.*x);
PN(x) = 1-PL(x);
PL(w) = exp(-beta.*w);
PN(w) = 1-PL(w);
D1(r) = (aN /k) *lambertw(0, (k/aN)* exp((k *r)/aN) * r^(aL/aN));
D2(r) = (aL /k) *lambertw(0, (k/aN)* exp((k *r)/aN) * r^(aL/aN));
% Association Probability
LA = N* (int( f(r)* PL(r) * ( int(PL(x)*f(x),x,r,xu) + int(PN(x)*f(x),x,D1(r),xu))^(N-1),r,h_A,xu));
NA = N* (int( f(r)* PN(r) * ( int(PN(x)*f(x),x,r,xu) + int(PL(x)*f(x),x,D2(r),xu))^(N-1),r,h_A,xu));
% Servig distance distribution
fRL(r)= ( N * PL(r) * f(r)* ( int(PL(x)*f(x),x,r,xu) + int(PN(x)*f(x),x,D1(r),xu))^(N-1) ) / LA ;
fRN(r)= ( N * PN(r) * f(r)* ( int(PN(x)*f(x),x,r,xu) + int(PL(x)*f(x),x,D2(r),xu))^(N-1) ) / NA ;
% Interfernce distance distribution
fWLL = PL(w)*f(w) / (int(PL(x)*f(x),w,r,xu));
fWN = PN(w)*f(w) / (int(PN(x)*f(x),w,D1(r),xu));
fWNL = PL(w)*f(w) / (int(PL(x)*f(x),w,D2(r),xu));
fWNN = PN(w)*f(w) / (int(PN(x)*f(x),w,r,xu));
PLA = (int(PL(x)*f(x),x,r,xu)) / ( int(PL(x)*f(x),x,r,xu) + int(PN(x)*f(x),x,D1(r),xu)) ;
PNA = (int(PN(x)*f(x),x,D1(r),xu)) / ( int(PL(x)*f(x),x,r,xu) + int(PN(x)*f(x),x,D1(r),xu)) ;
PeqL = 1/ ( int(PL(x)*f(x),x,r,xu) + int(PN(x)*f(x),x,D1(r),xu));
PeqN = 1/ ( int(PN(x)*f(x),x,r,xu) + int(PL(x)*f(x),x,D2(r),xu));
PcT = zeros(length(thresh));
U = thresh / PA * GA * Gu * L * r^(-aL) * exp(-k * r);
U1 = thresh / PA * GA * Gu * L * r^(-aN) * exp(-k * r);
for T = 1:length(thresh)
LTL=0;
for i=1:length(B)
F1 = int( PL(w)*f(w) * (1/(1+ U(T) * PA * B(i) * w^(-aL) * exp(-k * w))),w,r,xu);
F2 = int( PN(w)*f(w) * (1/(1+ U(T) * PA * B(i) * w^(-aN) * exp(-k * w))),w,D1(r),xu);
LTL = LTL + (F1 + F2) * pa(i) ;
end
LTN=0;
for i=1:length(B)
F1 = int( PN(w)*f(w) * (1/(1+ U1(T) * PA * B(i) * w^(-aN) * exp(-k * w))),w,r,xu);
F2 = int( PL(w)*f(w) * (1/(1+ U1(T) * PA * B(i) * w^(-aL) * exp(-k * w))),w,D2(r),xu);
LTN = LTN + (F1 + F2) * pa(i) ;
end
PcT(T) =LA * exp(-U(T) * np) * (PeqL*LTL)^(N-1) + NA * exp(-U1(T) * np) * (PeqN*LTN)^(N-1);
end
plot(thresh_dB,PcT,'r','LineWidth',1.5)
legend ('analytical result')
hold on

Answers (1)

Walter Roberson
Walter Roberson on 18 Mar 2024
PcT = zeros(length(thresh));
PcT is assigned as numeric zeros.
F1 = int( PL(w)*f(w) * (1/(1+ U(T) * PA * B(i) * w^(-aL) * exp(-k * w))),w,r,xu);
F1 and F2 are int() and so are symbolic. So your LTL and LTN are symbolic.
PcT(T) =LA * exp(-U(T) * np) * (PeqL*LTL)^(N-1) + NA * exp(-U1(T) * np) * (PeqN*LTN)^(N-1);
symbolic expressions to the power of 9 can take a long time to compute. The result is going to be a symbolic expression. But the result has to be assigned into the double-precision location PcT(T)
The question then becomes whether the resulting symbolic expression can be converted to double precision; the answer to that is NO.
  4 Comments

Sign in to comment.

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!