what does this error error mean? "Array formation and parentheses-style indexing with objects of class 'phased.Ph​aseShiftBe​amformer' is not allowed. Use objects of class 'phased.Ph​aseShiftBe​amformer' only as scalars or use a cell array."

12 views (last 30 days)
I am making a program to acheive delay and sum beamforming,
I looked for examples of this online and found one relatable. The code is given below. When i run the program i get this error
"Array formation and parentheses-style indexing with objects of class 'phased.PhaseShiftBeamformer' is not allowed. Use
objects of class 'phased.PhaseShiftBeamformer' only as scalars or use a cell array."
I am using 2015 version of Matlab. Can someone please help.
Code:
t = 0:0.001:0.3; % Time, sampling frequency is 1kHz
s = zeros(size(t));
s = s(:); % Signal in column vector
s(201:205) = s(201:205) + 1; % Define the pulse
plot(t,s);
title('Pulse');xlabel('Time (s)');ylabel('Amplitude (V)');
carrierFreq = 100e6;
wavelength = physconst('LightSpeed')/carrierFreq;
% here, the no. of receiving antennas are 10
ula = phased.ULA('NumElements',10,'ElementSpacing',wavelength/2);
ula.Element.FrequencyRange = [90e5 110e6];
%assuming signal arrives at the array at an angle of 45 in azimuth and 0 in elevation
inputAngle = [45; 90];
x = collectPlaneWave(ula,s,inputAngle,carrierFreq);
% if thermal noise is to be taken into account
% Create and reset a local random number generator so the result is the
% same every time.
rs = RandStream.create('mt19937ar','Seed',2008);
noisePwr = .5; % noise power
noise = sqrt(noisePwr/2)*(randn(rs,size(x))+1i*randn(rs,size(x)));
% noise = 0;
rxSignal = x + noise;
subplot(211);
plot(t,abs(rxSignal(:,1)));axis tight;
title('Pulse at Antenna 1');xlabel('Time (s)');ylabel('Magnitude (V)');
subplot(212);
plot(t,abs(rxSignal(:,2)));axis tight;
title('Pulse at Antenna 2');xlabel('Time (s)');ylabel('Magnitude (V)');
%%
psbeamformer = phased.PhaseShiftBeamformer('SensorArray',ula,'OperatingFrequency',carrierFreq,'Direction',inputAngle,'WeightsOutputPort', true);
[yCbf,w] = psbeamformer(rxSignal);
% Plot the output
clf;
plot(t,abs(yCbf)); axis tight;
title('Output of Phase Shift Beamformer');
xlabel('Time (s)');ylabel('Magnitude (V)');

Answers (1)

Honglei Chen
Honglei Chen on 6 Mar 2019
Let's say you have two objects
bf1 = phased.PhaseShiftBeamformer;
bf2 = phased.PhaseShiftBeamformer;
The message indicates that you cannot put these two objects in an array, like
[bf1, bf2] % this will error out
Instead, if you want to put them into an array, you have to use a cell array
{bf1 bf2} % this will be ok
HTH
  3 Comments
Honglei Chen
Honglei Chen on 6 Mar 2019
This may be a different issue, could you try to replace
[yCbf,w] = psbeamformer(rxSignal);
with
[yCbf,w] = step(psbeamformer,rxSignal);
and see if this resolves the issue? The syntax you used is probably not supported back in R2015.
HTH

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!