Skip to content
Snippets Groups Projects
Commit ace9b679 authored by Achilles Kappis's avatar Achilles Kappis
Browse files

Update arrMan.m to accept and use column position vectors and column directional vectors

parent a948e596
No related branches found
No related tags found
1 merge request!8Convert project to use column vectors
......@@ -3,7 +3,7 @@
% Author: Achilles Kappis
% e-mail: axilleaz@protonmail.com
%
% Date: 28/05/2024 (DD/MM/YYYY)
% Date: 29/09/2024 (DD/MM/YYYY)
%
% Copyright: MIT
% --------------------------------------------------
......@@ -13,12 +13,12 @@
% Input
%
% mPos [numeric]: The positions of the sensors in Cartesian coordinates.
% This must be an Mx3 matrix where M denotes the number of
% This must be an 3xM matrix where M denotes the number of
% sensors and for each sensor the coordinates are in
% [x, y, z] format.
% [x; y; z] format.
%
% dirs [numeric]: These are the directions for which the array manifold
% will be calculated. This must be an Nx2 matrix where N is
% will be calculated. This must be an 2xN matrix where N is
% the number of directions and for each direction the
% azimuth and elevation/inclination is given. The values
% must be provided in radians. The directions must be
......@@ -53,18 +53,18 @@ function am = arrMan(mPos, dirs, k)
% Validate input arguments
% ====================================================
% Validate mandatory arguments
validateattributes(mPos, "numeric", {'2d', 'finite', 'nonnan', 'nonempty', 'real', 'ncols', 3}, mfilename, "Position of sensors", 1);
validateattributes(dirs, "numeric", {'2d', 'finite', 'nonnan', 'nonempty', 'real', 'ncols', 2}, mfilename, "Directions of interest", 2);
validateattributes(mPos, "numeric", {'2d', 'finite', 'nonnan', 'nonempty', 'real', 'nrows', 3}, mfilename, "Position of sensors", 1);
validateattributes(dirs, "numeric", {'2d', 'finite', 'nonnan', 'nonempty', 'real', 'nrows', 2}, mfilename, "Directions of interest", 2);
validateattributes(k, "numeric", {'vector', 'finite', 'nonnan', 'nonempty', 'nonnegative', 'real'}, mfilename, "Wavenumbers of interest", 3);
% =============================================
% Calculate the array manifold
% =============================================
% Get Cartesian coordinates of directions
[x, y, z] = sph2cart(dirs(:, 1), dirs(:, 2), ones(size(dirs(:, 1))));
[x, y, z] = sph2cart(dirs(1, :), dirs(2, :), ones(size(dirs(1, :))));
% Inner product of directions and sensor position
am = mPos * [x, y, z].';
am = [x; y; z] * mPos;
% Multiply with wavenumbers
am = am .* permute(k(:), [3, 2, 1]);
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment