How to solve too many arguments error in the bold part

21 views (last 30 days)
clc
clear all
close all
L=12; % IRS
element=10;
lambda=0.06;
l=lambda/2;
K=4;
radius=15;
X0=0; % x-coordinate of Centre of the circle
Y0=0; % y-coordinate of centre of circle
%% Users
t = 2*pi*rand(K,1);
R = radius*sqrt(rand(K,1));
x_u = X0 + R.*cos(t); % X-coordinate of the Users
y_u = Y0 + R.*sin(t); % Y-coordinate of the Users
%% Base stations
x_b=[0.7298; 3; -5.23; 11.86]; % x coordinate of base station
y_b=[12.48; -1.497; -6.139; -3.23]; %y coordiante of base station
%% IRS Elements
X3=[-7.655; -6.189; -3.251; 2.926; 6.534; 10.79; 5.203; -4.465; 1.42; -8.66; -0.8748; 6.534] ;
Y3=[1.393; 10.42; 6.639; 5.821; 8.425; 2.924; 1.139; 0.7508; -7.917; -6.928; -10.01; -7.03];
p=0;
%% loop for the elements of irs
N=100:100:300;
NN = length(N) ;
% x_e = zeros(element,NN/10,L,NN);
% y_e = zeros(element,NN/10,L,NN);
for n = 1:length(N)
nn=N(n);
for i=1:L
for j=1:element
for k=1:(nn)/(10)
x3(j,k,i) = X3(i,1) + p;
y3(j,k,i) = Y3(i,1);
p=k*l; % Each time lambda is added to the x-coordinate
x_e(j,k,i,n) = x3(j,k,i); % X coordinate of an element of IRS for plotting
y_e(j,k,i,n)= y3(j,k,i); % Y coordinate of an element of IRS for plotting
end
p=0;
Y3(i,1) = Y3(i,1) + l;
end
% plot(x3,y3,'bo','HandleVisibility','off')
end
end
%% Distance compution between IRSs
for iteration = 1:length(N) % Iterations
nn=N(n);
for irs1 = 1:(L-1) % IRS1 to be multiplied
for j1 = 1:element % row of 1st IRS
for k1 = 1:(nn/10) % column of 1st IRS
for irs2 = (irs1+1):L % IRS2 to be multiplied
for j2 = 1:element % row of 2nd IRS
for k2 = 1:(nn/10) % column of 2nd IRS
de_e(irs1,j1,k1,irs2,j2,k2,iteration) = sqrt(((x_e(j2,k2,irs2,iteration)-x_e(j1,k1,irs1,iteration))^2)+((y_e(j2,k2,irs2,iteration)-y_e(j1,k1,irs1,iteration))^2));
end
end
end
end
end
end
end
%% Distance computation between IRSs and Base Station
for s=1:4
% error at h_eb
d_eb(:,:,:,:,s) = sqrt(((x_e-x_b(s,1)).^2)+((y_e-y_b(s,1)).^2)); % distance between base station and IRS
h_eb(:,:,:,:,s)=(sqrt(alpha)./(d_eb(:,:,:,:,s))).*(exp(-1j*(2*pi*d_eb(:,:,:,:,s))./lambda)); % channel between Irs and base station
% distance between user and IRS's
d_ue(:,:,:,:,s)=sqrt(((x_u(s,1)-x_e).^2)+((y_u(s,1)-y_e).^2)); % distance
h_ue(:,:,:,:,s)=(sqrt(alpha)./(d_ue(:,:,:,:,s))).*(exp(-1j*(2*pi*d_ue(:,:,:,:,s))/lambda));% channel between User and IRS
%
end

Answers (1)

Geoff Hayes
Geoff Hayes on 1 Feb 2022
@Maimoona Asad - I see the same error when I run your code
Error using alpha
Too many output arguments.
Error in myfunction (line 71)
h_eb(:,:,:,:,s)=(sqrt(alpha)./(d_eb(:,:,:,:,s))).*(exp(-1j*(2*pi*d_eb(:,:,:,:,s))./lambda)); % channel
between Irs and base station
. This is because the alpha function is being called which doesn't have any output parameters and so the error makes sense given that the code is trying to call the square root of that output. I don't think you mean to be using alpha here. Perhaps you mean this to be a variable instead..one that isn't defined in your code or maybe one that has a different name (that is defined in your code).

Tags

Community Treasure Hunt

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

Start Hunting!