Beamforming with microphone arrays

14 views (last 30 days)
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
Ali Movahed
Ali Movahed on 3 Jan 2017
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',...
Nick Yiw
Nick Yiw on 18 Mar 2019
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

Honglei Chen
Honglei Chen on 3 Jan 2017
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
Honglei Chen
Honglei Chen on 4 Jan 2017
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!