what does this error error mean? "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."
13 ビュー (過去 30 日間)
古いコメントを表示
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)');
0 件のコメント
回答 (1 件)
Honglei Chen
2019 年 3 月 6 日
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 件のコメント
Honglei Chen
2019 年 3 月 6 日
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
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!