Error using fminbnd with meijerG function
3 次查看(过去 30 天)
显示 更早的评论
Hi all,
I want to get the minimun value for the function using meijerG, but there is error message from meijerG with not enough input arguments.
Error using meijerG (line 26)
Not enough input arguments.
How to solve this issue?
Here is my code:
%% clear all
clear; close; clc;
syms h;
P0 = 20 ; %Power of signal (dBm)
N0 = -190; %Power of noise (dBm)
R_th = 10^(-0.2); %bit/s
xi = 0.5; % harvesting and transmission time ratio
B = 20; %total bandwidth
n = 10; % sensor number
k = (n/2); % Group number
r_edge = 100:50:1400; %edge of the coverage area
beta = 0.5; % the power ratio in relaying scenario
zeta_c = 0.35;
P_ungrouped_anal_s1 = zeros(length(r_edge),length(h));
P_ungrouped_anal_s2 = zeros(length(r_edge),length(h));
P_anal = zeros(length(r_edge),length(h));
for rindex = 1:length(r_edge)
% location of sensors
d_u = zeros(1,n);
d_r_1 = zeros(1,(n/2));
theta_u = zeros(1,n);
d_r_2 = zeros(1,(n/2));
% bubble
phi0 = [1.77889960366859,...
3.40209352082120,...
3.20476297393434,...
4.10097788597444,...
3.42435000592408,...
5.36900245309958,...
0.365946328054284,...
6.26162943668968,...
3.98141804596101,...
2.60253155255856];
r0 = [0.482018471214377,...
0.998215966013273,...
0.253203877297839,...
0.863165479150165,...
0.657410820449216,...
0.928635167658301,...
0.381438939031673,...
0.563850286614375,...
0.906194849015169,...
0.156921509752021];
r800 = r0*r_edge(rindex);
r = length(r0);
for i = 1: r-1
for j = i+1:r
if r800(i)>r800(j)
t_r = r800(j);
r800(j) = r800(i);
r800(i) = t_r;
t_phi = phi0(j);
phi0(j) = phi0(i);
phi0(i) = t_phi;
end
end
end
r_u = r800;
phi = phi0;
r_u_c = zeros(1,n/2);
r_u_1 = zeros(1,n/2);
r_u_2 = zeros(1,n/2);
alpha_c = sym(zeros(1,n/2));
alpha_1 = sym(zeros(1,n/2));
alpha_2 = sym(zeros(1,n/2));
% m_c = zeros(1,n/2);
% m_1 = zeros(1,n/2);
% m_2 = zeros(1,n/2);
% zeta_c = zeros(1,n/2);
% zeta_1 = zeros(1,n/2);
% zeta_2 = zeros(1,n/2);
d_u_c = sym(zeros(1,n/2));
d_u_1 = sym(zeros(1,n/2));
d_u_2 = sym(zeros(1,n/2));
theta_u_c = sym(zeros(1,n/2));
theta_u_1 = sym(zeros(1,n/2));
theta_u_2 = sym(zeros(1,n/2));
for i = 1:n/2
r_u_c(i) = r_u(i);
r_u_1(i) = r_u(i+n/2);
r_u_2(i) = r_u(n-i+1);
end
% phi = zeros(1,n);
phi_u_1 = zeros(1,(n/2));
phi_u_2 = zeros(1,(n/2));
for i=1:n/2
% r_u(i) = (i-1)*r_edge/(n-1);
d_u_c(i) = sqrt(h^2+(r_u_c(i)^2)); %sensor to uav distance
d_u_1(i) = sqrt(h^2+(r_u_1(i)^2));
d_u_2(i) = sqrt(h^2+(r_u_2(i)^2));
theta_u_c(i) = atan(h/r_u_c(i)); %angle
theta_u_1(i) = atan(h/r_u_1(i));
theta_u_2(i) = atan(h/r_u_2(i));
end
% degree between different sensors
for i = 1:(n/2)
% s1
if abs(phi(i+n/2)-phi(i)) <= pi
phi_u_1(i) = abs(phi(i+n/2)-phi(i));
else
phi_u_1(i) = 2 * pi - abs(phi(i+n/2)-phi(i));
end
% s2
if abs(phi(n-i+1)-phi(i)) <= pi
phi_u_2(i) = abs(phi(n-i+1)-phi(i));
else
phi_u_2(i) = 2 * pi - abs(phi(n-i+1)-phi(i));
end
end
% distances in different sensors
for i=1:n/2
% s1
if abs(phi(i+n/2)-phi(i)) <= pi
d_r_1(i) = sqrt(r_u(i)^2 + r_u(i+(n/2))^2 ...
- 2*r_u(i)*r_u(i+(n/2))*cos(abs(phi(i+(n/2))-phi(i))));
else
d_r_1(i) = sqrt(r_u(i)^2 + r_u(i+(n/2))^2 ...
- 2*r_u(i)*r_u(i+(n/2))*cos(abs(2*pi-(phi(n-i+1)-phi(i)))));
end
% s2
if abs(phi(n-i+1)-phi(i)) <= pi
d_r_2(i) = sqrt(r_u(i)^2 + r_u(n-i+1)^2 ...
- 2*r_u(i)*r_u(n-i+1)*cos(abs(phi(n-i+1)-phi(i))));
else
d_r_2(i) = sqrt(r_u(i)^2 + r_u(n-i+1)^2 ...
- 2*r_u(i)*r_u(n-i+1)*cos(abs(2*pi-(phi(n-i+1)-phi(i)))));
end
end
% pathloss and rician factor
alpha_0 = 3.5;
alpha_pi = 2;
Kappa_0 = 5; %db
Kappa_pi = 15;
kappa_0 = 10^(Kappa_0/10);
kappa_pi = 10^(Kappa_pi/10);
% nakagami-m fading
m = sym(zeros(1,n));
omega = zeros(1,n);
m_0 = (kappa_0 + 1)^2/(2*kappa_0 + 1);
for i = 1:n
m(i) = (kappa_0 * (kappa_pi/kappa_0)^(2*theta_u(i)/pi)+1)^2 ...
/ (2*kappa_0*(kappa_pi/kappa_0)^(2*theta_u(i)/pi)+1);
omega(i) = 1;
end
% Path-loss exponent
% a,b
a = 0;
b = 0;
% alpha beta gamma parameters
alpha_ab = 0.1;
beta_ab = 750;
gamma_ab = 8;
C_a = [9.34e-1, 2.30e-1, -2.25e-3, 1.86e-5; ...
1.97e-2, 2.44e-3, 6.58e-6, NaN; ...
-1.24e-4, -3.34e-6, NaN, NaN; ...
2.73e-7, NaN, NaN, NaN];
C_b = [1.17, -7.56e-2, 1.98e-3, -1.78e-5; ...
-5.79e-3, 1.81e-4, -1.65e-6, NaN; ...
1.73e-5, -2.02e-7, NaN, NaN; ...
-2.00e-8, NaN, NaN, NaN];
for j = 0:1:3
for i = 0:1:3-j
a = a + C_a(j+1,i+1) * (alpha_ab*beta_ab)^i * gamma_ab^j;
b = b + C_b(j+1,i+1) * (alpha_ab*beta_ab)^i * gamma_ab^j;
end
end
% Path-loss alpha
for i = 1:n/2
alpha_c(i) = (alpha_pi-alpha_0) ...
* (1/(1+a*exp(-b*theta_u_c(i)))) ...
+ alpha_0;
alpha_1(i) = (alpha_pi-alpha_0) ...
* (1/(1+a*exp(-b*theta_u_1(i)))) ...
+ alpha_0;
alpha_2(i) = (alpha_pi-alpha_0) ...
* (1/(1+a*exp(-b*theta_u_2(i)))) ...
+ alpha_0;
end
% backscatter efficiency
zeta = zeta_c;
p_P0 = 10^(P0/10)*10^(-3); % Transmitter
p_N0 = 10^(N0/10)*10^(-3); % Noise
P_d1_n_1 = sym(zeros(1,n/2));
P_d1_n_2 = sym(zeros(1,n/2));
prod_d1 = 1;
for i = 1:n/2
% s1 direct
Z_1 =(2^(k*R_th/(B*(1-xi)))-1)*zeta/zeta*d_u_c(i)^(2*alpha_c(i))/d_u_1(i)^(2*alpha_1(i));
Z_2 =(2^(k*R_th/(B*(1-xi)))-1)*p_N0*d_u_1(i)^(2*alpha_1(i))/(zeta*xi/(1-xi)*p_P0);
P_d1_n_1(i) = 1 - 1 ...
/ (gamma(m(i))^2 * gamma(m(i+n/2)))^2 ...
* meijerG([1,1-m(i+n/2), 1-m(i+n/2)],[],[m(i), m(i)],0, ...
m(i)^2 * Z_1 / m(i+n/2)^2);
P_d1_n_2(i) = 1 - 1 /gamma(m(i+n/2))^2 ...
* meijerG(1, [], [m(i+n/2),m(i+n/2)],0, ...
m(i+n/2)^2*Z_2);
prod_d1 = prod_d1 ...
* (1-P_d1_n_1(i)) * (1-P_d1_n_2(i));
end
P_d_s1_anal = 1 - prod_d1;
P_d_s1 = matlabFunction(P_d_s1_anal);
h0 = [300,800];
x = fminbnd(P_d_s1, 300, 800)
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Robust Control Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!