Nc=31; N=5; M=3; K=3; tot_len=200;
array_TX =[3.5086 0 0;2.6877 2.2553 0;0.6093 3.4553 0;-1.7543 3.0385 0;-3.2970 1.2000 0;
-3.2970 -1.2000 0;-1.7543 -3.0385 0;0.6093 -3.4553 0;2.6877 -2.2553 0];
array_RX =[0.8507 0 0;0.2629 0.8090 0;-0.6882 0.5000 0;
-0.6882 -0.5000 0;0.2629 -0.8090 0];
DOA =[270 180 70 89 158 204 208 339 167].';
DOD =[40 120 150 195 223 161 75 350];
91
recvd_data = myreceived_data(Nc,N,M,K,tot_len,array_TX,DOD,array_RX,DOA);

2 commentaires

Walter Roberson
Walter Roberson le 16 Sep 2021
myreceived_data is not a Mathworks function, but the problem is occurring inside it. We would need the code.
Thank you very much dear Walter Roberson for your response. The requirede function is as below:
%1-Received data
function recvd_data = myreceived_data(Nc,N_bar,N,M,K,tot_len,array_TX,DOD,array_RX,DOA)
recvd_data1 = zeros(N,tot_len*Nc);
shift_data = zeros(N_bar,tot_len*Nc,M,K);
for m = 1:M
for k = 1:K
shift_data(:,:,m,k) = circshift(data_tx_ss(:,:,m),[0,delays(m,k)]); % Shift circularly columns of matrix towards right
end
end
for m = 1:M
for k = 1:K
for t = 1:tot_len
S_TX = spv(array_TX, [DOD(k+(m-1)*K) 0]);
S_RX = spv(array_RX, [DOA(k+(m-1)*K) 0]);
recvd_data(:,Nc*(t-1)+1:Nc*t) = recvd_data1(:,Nc*(t-1)+1:Nc*t) + (beta(k+(m-1)*K,t)*S_RX).*(S_TX'*shift_data(:,Nc*(t-1)+1:Nc*t,m,k));% it is x(t) in eq.(6)
end
end
end
end % function end

Connectez-vous pour commenter.

 Réponse acceptée

Fernando Peña
Fernando Peña le 16 Sep 2021

0 votes

When calling the function, you are missing the variable N_bar.

5 commentaires

Sadiq Akbar
Sadiq Akbar le 16 Sep 2021
Thanks for your response dear Fernando Peña. Yes I have forgotten in writing here. N_bar=9; But thats not the reason. Even if you provide N_bar=9; to the calling function still it says:
Error using zeros
Size inputs must be scalar.
Error in myreceived_data (line 4)
recvd_data1 = zeros(N,tot_len*Nc);
I'll try to explain it in a clearer way:
In the line:
recvd_data = myreceived_data(Nc,N,M,K,tot_len,array_TX,DOD,array_RX,DOA);
The argument "N_bar" is not included. Then, as an argument is missing, the function is taking "array_TX" (matrix, non scalar) as the argument corresponding to "tot_len".
You should write instead:
recvd_data = myreceived_data(Nc,N_bar,N,M,K,tot_len,array_TX,DOD,array_RX,DOA);
I hope this way it's easier to understand.
Thank you very much dear Fernando Peña for your guidance. Yes, you are rigth. But why this gives error?
M=3;Nc=31; N_bar=9; N=5; M=3; K=3; tot_len=200;delays=[1 9 15;18 27 22;16 16 22];
mseq1=[1 1 1 1 1 0 0 0 1 1 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 0 0
].';
mseq2=[1 1 1 1 1 0 1 1 1 0 0 0 1 0 1 0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 0
].';
recvd_data = myreceived_data(Nc,N_bar,N,M,K,tot_len,array_TX,DOD,array_RX,DOA, data_tx_ss,delays)
[cost_func]=recvd_data_preproc(M,Nc,N,N_bar,tot_len,recvd_data,mseq1,mseq2);
%2-Pre-processig the Received data
function [cost_func]=recvd_data_preproc(M,Nc,N,N_bar,tot_len,recvd_data,mseq1,mseq2)
%[cost_func]=recvd_data_preproc(M,Nc,N,N_bar,tot_len,recvd_data,mseq1,mseq2);
temp = mseq1;
Code_matrix = zeros(Nc,N_bar,M); % line 23 in main code
for m = 1:M %user no.
for i = 1:N_bar % Tx antenna no.
temp = circshift(temp,[1 0]); % shifts elements in column vector "temp" by 1 towards down
Code_matrix(:,i,m) = xor(temp,mseq2); % code matrix (31 x 9) for each user
end
end
Code_matrix = 1-2.*Code_matrix;
for m = 1:M
data_tx = (randn(1,tot_len) + 1i*randn(1,tot_len))/sqrt(2); % Random row vector 1x200
Code_mat_temp = Code_matrix(:,:,m); % 31 x 9
shift = 0;
for n = 1:N_bar
data_tx_ss(n,:,m) = kron(data_tx, Code_mat_temp(:,n)');
end
end
Code_mat_des = Code_matrix(:,:,1);
%received matrix N*Nc*L ( where L means total no. of snapshots)
recvd_3D_cube = zeros(N,Nc,tot_len);
for l = 1:tot_len-1
startpt = (l-1)*Nc+1; % ???????
endpt = startpt + Nc-1; % ???????
recvd_3D_cube(:,:,l) = recvd_data(:,startpt:endpt);
end
recvd_data_preproco = zeros(N*N_bar,tot_len);
for l = 1:tot_len
temp_mat = [];
for m = 1:N_bar
temp = recvd_3D_cube(:,:,l)*Code_mat_des(:,m);
temp_mat = cat(2,temp_mat,temp); % (1st matrix then 2nd matrix in same level but cat(1,temp_mat,temp) will keep 1st matrix then 2nd matrix just below)
end
recvd_data_preproco(:,l) = temp_mat(:);
end
Rxx = recvd_data_preproc*recvd_data_preproc'./tot_len; % (Covariance matrix from recvd_data_preproc)
[E,D] = eig(Rxx); % (Eigen vectors matrix E and diadonal matrix D haiving eigen values on main diagonal)
[D,order] = sort(abs(diag(D)),'descend'); %(Arrange eigen values in decending order)
%%
% figure;
% plot(10*log10(D));
E = E(:,order); %(Arrange eigen vectors in same order as are eigen values)
Esig = E(:,1:2*M*K);
P_En = eye(N*N_bar) - Esig*pinv(Esig'*Esig)*Esig';
% figure
dod_arr = 0:2:360; % 1 x 181
doa_arr = 0:2:360; % 1 x 181
cost_func = zeros(length(doa_arr));
J = fcreateJ(Nc); % 31 x 31 matrix such that 1st entire row is zero,then in 2nd row,1st element is 1 and remaining are all 0's, then this is shifted in 3rd row by 1 position towards right, then same is done for 3rd row and so on
index1 = 1;
for doa = doa_arr
index2 = 1;
for dod = dod_arr
for k =1:3
A_temp = (Code_mat_des'*J^delays(1,k)*Code_mat_des)/Nc;
A = kron(A_temp,eye(N));
S = spv(array_RX,[doa 0]);
S_bar = spv(array_TX,[dod 0]);
S_man = kron(conj(S_bar),S);
cost_func(index1,index2) = cost_func(index1,index2)+(S_man'*A'*A*S_man)./(S_man'*A'*P_En*A*S_man);
end
index2 = index2+1;
end
index1 = index1 + 1;
doa; % semi colon put by Me
end
end
Walter Roberson
Walter Roberson le 16 Sep 2021
Modifié(e) : Walter Roberson le 21 Sep 2021
Because Array_TX is not defined by that code.
Sadiq Akbar
Sadiq Akbar le 21 Sep 2021
Yes you are rigth dear Walter Roberson. Thank you so much.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by