Beamforming with microphone arrays

Hello everyone, I have 16 microphones in my code trying to have the 2d Response pattern of the Sound source. The Position of the source is defined in the code and I suppose to get a 2d diagram which Shows the power of the source in dB. I run this code and get an error which is does nor make any sense to me. could you please give me your comments?
% Define my microphone array
h = phased.ConformalArray();
t= 1/2*(1+sqrt(5));
n=16;
c= ones(n,1)';
c(:)=1:16;
h.ElementPosition = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;(sqrt(c).*cos(2*pi*t*c))*0.0375;(sqrt(c).*sin(2*pi*t*c))*0.0375];
h.ElementNormal = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 ...
0 0 0 0 0 0 0 0 0 0 0];
h.Element = ...
phased.OmnidirectionalMicrophoneElement('BackBaffled',true,'FrequencyRange',[48e3 580e3]);
% Define my Signal
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
carrierFreq = 100e6;
wavelength = physconst('LightSpeed')/carrierFreq;
inputAngle = [45; 0];
x = collectPlaneWave(h,s,inputAngle,carrierFreq);
% Define the MVDR beamformer
mvdrbeamformer = phased.MVDRBeamformer('SensorArray',h,...
'Direction',inputAngle,'OperatingFrequency',carrierFreq,...
'WeightsOutputPort',true);
% Pattern
pattern(h,carrierFreq,-180:180,0,'Weights',true,'Type','powerdb',...
'PropagationSpeed',physconst('LightSpeed'),'Normalize',false,...
'CoordinateSystem','rectangular');
axis([-90 90 -80 20]);

2 Comments

here is the Error: Undefined function 'pattern' for input arguments of type 'phased.ConformalArray'.
Error in Newbeamforming (line 26) pattern(h,carrierFreq,-180:180,0,'Weights',true,'Type','powerdb',...
Hi, I am a student currently working on a project that involves distance speech recognition for controlling output. I really want to know what are the best recommendations of microphone arrays/chips that I can use which are compatible with MATLAB. Thank you.

Sign in to comment.

 Accepted Answer

Looks like you are using an older version of the toolbox. Which release are you using? Instead of using
pattern(h,carrierFreq,-180:180,0,'Weights',true,'Type','powerdb',...
'PropagationSpeed',physconst('LightSpeed'),'Normalize',false,...
'CoordinateSystem','rectangular');
axis([-90 90- -80 20])
try
plotResponse(h,10e4,physconst('LightSpeed'),'Format','line',...
'RespCut','az','Unit','db','NormalizeResponse',false);
and see if it works.
BTW, the argument following the 'weights' parameter should be a numerical vector containing the array weights instead of a logical. I'm not sure what you want to put in there so I ignored it. Also the frequency specified in pattern() is 100e6 yet the elements only work between 48 kHz and 580 kHz, so I used 100 kHz in my example.
HTH

6 Comments

thank you so much. your solution worked very well. When I want to set weights, I get another error. I add just one line to the same part which u changed.
[yCbf,w]= mvdrbeamformer(x);
pattern(h,carrierFreq,-180:180,0,'Weights',w,'Type','powerdb',...
'PropagationSpeed',physconst('LightSpeed'),'Normalize',false,...
'CoordinateSystem','rectangular');
axis([-90 90 -80 20]);
and I get this error: Array formation and parentheses-style indexing with objects of class 'phased.MVDRBeamformer' is not allowed. Use objects of class 'phased.MVDRBeamformer' only as scalars or use a cell array.
Error in Newbeamforming (line 25) [yCbf,w]= mvdrbeamformer(x); Thank you.
In your release, you would have to do
[yCbf,w] = step(mvdrbeamformer,x);
HTH
Hello, I have done that but again this error appears:
Warning: Matrix is singular to working precision.
> In lcmvweights>qrlinsolve at 97
In lcmvweights at 69
In MVDRBeamformer>MVDRBeamformer.stepImpl at 243
In Newbeamforming at 27
Warning: Matrix is singular to working precision.
> In lcmvweights>qrlinsolve at 98
In lcmvweights at 69
In MVDRBeamformer>MVDRBeamformer.stepImpl at 243
In Newbeamforming at 27
Undefined function 'pattern' for input arguments of type 'phased.ConformalArray'.
Error in Newbeamforming (line 28)
pattern(h,carrierFreq,-180:180,0,'Weights',w,'Type','powerdb',...
and could you please tell me with which function can I have the same result in 3D? somthing like plot Response 3D? Thank you.
The warning is indicates that the covariance matrix is not well constructed. I don't the dimension of x, but you may need more snapshots, i.e., more rows in that matrix.
The error is about pattern() so looks like you still have a call to pattern() in your script?
To plot 3D pattern, in the plotResponse() call, replace 'az', with '3d', like
plotResponse(h,10e4,physconst('LightSpeed'),'Format','line',...
'RespCut','3d','Unit','db','NormalizeResponse',false);
Ali Movahed
Ali Movahed on 13 Jan 2017
Edited: Ali Movahed on 13 Jan 2017
Hello, actually the size of x is 301*16 and all the values are Zero. I think some how weights are not calculated in my code. could you please calculate the weights[yCbf,w] = step(mvdrbeamformer,x); in your code when using plotResponse not Pattern? thank you.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!