# MATLAB example not working.

8 views (last 30 days)
Qasim Sultan on 7 Jul 2020
Edited: Stephen Cobeldick on 8 Jul 2020
Hi,
I am running code for plotting beam pattern by following webpage of MATLAB: https://in.mathworks.com/help/phased/examples/introduction-to-hybrid-beamforming.html
But MATLAB throws error:
"Undefined function 'scatteringchanmtx' for input arguments of type 'double'."
This code is provided by MATLAB team and still is not working. Your help will be highly appreciated. Code is provided below:
clc, clear all
Nt = 64;
NtRF = 4;
Nr = 16;
NrRF = 4;
rng(4096);
c = 3e8;
fc = 28e9;
lambda = c/fc;
txarray = phased.PartitionedArray(...
'Array',phased.URA([sqrt(Nt) sqrt(Nt)],lambda/2),...
'SubarraySelection',ones(NtRF,Nt),'SubarraySteering','None');
rxarray = phased.PartitionedArray(...
'Array',phased.URA([sqrt(Nr) sqrt(Nr)],lambda/2),...
'SubarraySelection',ones(NrRF,Nr),'SubarraySteering','None');
Ncl = 6;
Nray = 8;
Nscatter = Nray*Ncl;
% compute randomly placed scatterer clusters
txclang = [rand(1,Ncl)*120-60;rand(1,Ncl)*60-30];
rxclang = [rand(1,Ncl)*120-60;rand(1,Ncl)*60-30];
txang = zeros(2,Nscatter);
rxang = zeros(2,Nscatter);
% compute the rays within each cluster
for m = 1:Ncl
end
g = (randn(1,Nscatter)+1i*randn(1,Nscatter))/sqrt(Nscatter);
txpos = getElementPosition(txarray)/lambda;
rxpos = getElementPosition(rxarray)/lambda;
H = scatteringchanmtx(txpos,rxpos,txang,rxang,g);
F = diagbfweights(H);
F = F(1:NtRF,:);
pattern(txarray,fc,-90:90,-90:90,'Type','efield',...
'ElementWeights',F','PropagationSpeed',c);

Benjamin on 7 Jul 2020
Do you have the Phased Array System Toolbox installed?
Qasim Sultan on 8 Jul 2020
yes !

Stephen Cobeldick on 8 Jul 2020
Edited: Stephen Cobeldick on 8 Jul 2020
Typical reasons why that function might not work:
• scatteringchanmtx was introduced in R2017b. It will not work with earlier MATLAB versions. You did not tag the question with the MATLAB version you are using, but it helps us when you do.
• the toolbox is not installed (check using ver).
• the Search path has been changed so the function cannot be found.