<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>k-Wave User Forum &#187; Topic: Trouble With Figure-of-Eight (cos(theta)) Sensor Element Directivity in 2D</title>
		<link>http://www.k-wave.org/forum/topic/trouble-with-figure-of-eight-costheta-sensor-element-directivity-in-2d</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 00:57:56 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.k-wave.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.k-wave.org/forum/rss/topic/trouble-with-figure-of-eight-costheta-sensor-element-directivity-in-2d" rel="self" type="application/rss+xml" />

		<item>
			<title>bencox on "Trouble With Figure-of-Eight (cos(theta)) Sensor Element Directivity in 2D"</title>
			<link>http://www.k-wave.org/forum/topic/trouble-with-figure-of-eight-costheta-sensor-element-directivity-in-2d#post-6130</link>
			<pubDate>Sun, 10 Sep 2017 15:41:04 +0000</pubDate>
			<dc:creator>bencox</dc:creator>
			<guid isPermaLink="false">6130@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Rehman, &#60;/p&#62;
&#60;p&#62;When you say 'valid' what do you mean? You can do whatever you like if it gives you the directional response that matches the measured response you are trying to model. You might want to consider adding them, ie. modelling the directivity as a weighted sum of the pressure and gradient responses. &#60;/p&#62;
&#60;p&#62;Best wishes,&#60;br /&#62;
Ben
&#60;/p&#62;</description>
		</item>
		<item>
			<title>rehmanali1994 on "Trouble With Figure-of-Eight (cos(theta)) Sensor Element Directivity in 2D"</title>
			<link>http://www.k-wave.org/forum/topic/trouble-with-figure-of-eight-costheta-sensor-element-directivity-in-2d#post-6079</link>
			<pubDate>Sun, 30 Jul 2017 04:01:30 +0000</pubDate>
			<dc:creator>rehmanali1994</dc:creator>
			<guid isPermaLink="false">6079@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear Ben,&#60;/p&#62;
&#60;p&#62;Thank you so much for your reply. That adjustment produced the profiles I was expecting. I have one more question regarding this. &#60;/p&#62;
&#60;p&#62;I noticed that the directionalResponse function has two cases: one for simulating the sinc-based directivity (&#34;pressure&#34;), and one for simulating the cos(theta)-based directivity (&#34;gradient&#34;). My question is whether or not it would be possible to simulate both sources of directivity at the same time. In other words, is it possible to create a new case for that function as follows:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;case &#38;#39;total&#38;#39;
          % calculate magnitude of component of wavenumber along sensor face
         k_tangent = reshape([cos(theta) -sin(theta)]*sensor.directivity_wavenumbers, kgrid.Nx, kgrid.Ny);
         directionality_pressure = fftshift(sinc(k_tangent*sensor.directivity_size/2));
         % calculate magnitude of component of wavenumber normal to the sensor face
         k_normal = reshape([sin(theta), cos(theta)]*[kgrid.ky(:)&#38;#39;; kgrid.kx(:)&#38;#39;], kgrid.Nx, kgrid.Ny);
         temp = abs(k_normal./kgrid.k);
         temp(kgrid.k==0) = 0;
         directionality_gradient = fftshift(temp);
         % combine both sources of directivity
         directionality = directionality_pressure .* directionality_gradient;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I am wondering if it valid for me to simply multiply both sources of directivity to obtain the overall directivity.&#60;/p&#62;
&#60;p&#62;Thank You,&#60;br /&#62;
Rehman Ali
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bencox on "Trouble With Figure-of-Eight (cos(theta)) Sensor Element Directivity in 2D"</title>
			<link>http://www.k-wave.org/forum/topic/trouble-with-figure-of-eight-costheta-sensor-element-directivity-in-2d#post-6075</link>
			<pubDate>Tue, 25 Jul 2017 17:23:00 +0000</pubDate>
			<dc:creator>bencox</dc:creator>
			<guid isPermaLink="false">6075@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Rehman, &#60;/p&#62;
&#60;p&#62;Well spotted, thanks. You've uncovered a bug which we'll fix for the next version. If  you want to change it in the meantime, the bug is in the function &#60;code&#62;directionalResponse&#60;/code&#62;. Line 101 which currently reads&#60;/p&#62;
&#60;p&#62;&#60;code&#62;temp = k_normal./kgrid.k;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;needs to be changed to&#60;/p&#62;
&#60;p&#62;&#60;code&#62;temp = abs(k_normal./kgrid.k);&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Ben
&#60;/p&#62;</description>
		</item>
		<item>
			<title>rehmanali1994 on "Trouble With Figure-of-Eight (cos(theta)) Sensor Element Directivity in 2D"</title>
			<link>http://www.k-wave.org/forum/topic/trouble-with-figure-of-eight-costheta-sensor-element-directivity-in-2d#post-6060</link>
			<pubDate>Tue, 18 Jul 2017 00:28:09 +0000</pubDate>
			<dc:creator>rehmanali1994</dc:creator>
			<guid isPermaLink="false">6060@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Please try running the code below to see the issue I mentioned above:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;% =========================================================================
% DEFINE THE GRID AND MEDIUM PROPERTIES
% =========================================================================

% create the computational grid
Nx = 128;        % number of grid points in the x (row) direction
Ny = 128;        % number of grid points in the y (column) direction
dx = 1e-3/Nx;   % grid point spacing in the x direction [m]
dy = dx;     	% grid point spacing in the y direction [m]
kgrid = makeGrid(Nx, dx, Ny, dy);
x = (-(Nx-1)/2:(Nx-1)/2)*dx;
y = (-(Ny-1)/2:(Ny-1)/2)*dy;

% define the properties of the propagation medium
medium.sound_speed = 1500;  % [m/s]

% create the time array, then halve it to make the example end sooner
[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed);
kgrid.t_array = (0:0.7*length(kgrid.t_array))*dt;

% =========================================================================
% DEFINE THE DIRECTIONAL SENSOR ARRAY
% =========================================================================

% define a line of sensor points
sensor.mask = zeros(Nx,Ny);
depth_idx = 24;
lat_idx = 2:1:Ny-1;
sensor.mask(depth_idx, lat_idx) = 1;

% define the angle of max directivity for each sensor point:
%    0             = max sensitivity in x direction (up/down)
sensor.directivity_angle = zeros(Nx,Ny);

% define the directivity pattern
sensor.directivity_pattern = &#38;#39;gradient&#38;#39;; % Cosine-Based Directivity
%sensor.directivity_pattern = &#38;#39;pressure&#38;#39;; % Sinc-Based Directivity

% define the directivity size
sensor.directivity_size = 16*kgrid.dx;

% =========================================================================
% SIMULATION AND VISUALISATION FOR TIME-VARYING SOURCE PROBLEM
% =========================================================================

% define a time varying sinusoidal source (instead of an initial pressure)
source.p_mask = zeros(Nx,Ny);
source.p_mask(90, 64) = 1;
source.p0 = [];
source_freq = 12e6;
source_mag = 20.25;
source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array);

% run the simulation
input_args = {&#38;#39;PMLInside&#38;#39;, false, &#38;#39;PlotPML&#38;#39;, false, &#38;#39;PMLAlpha&#38;#39;, 2000};
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});

% plot the largest value of the output for each sensor
max_data = max(sensor_data(:, 150:end), [], 2);
figure, plot(y(lat_idx)&#38;#39;, max_data./max(max_data),&#38;#39;o&#38;#39;)
xlabel(&#38;#39;sensor lateral location (m)&#38;#39;)
ylabel(&#38;#39;maxima of single-element sensors&#38;#39;&#38;#39; outputs&#38;#39;)
axis([min(y) max(y) 0 1.05])&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>rehmanali1994 on "Trouble With Figure-of-Eight (cos(theta)) Sensor Element Directivity in 2D"</title>
			<link>http://www.k-wave.org/forum/topic/trouble-with-figure-of-eight-costheta-sensor-element-directivity-in-2d#post-6059</link>
			<pubDate>Tue, 18 Jul 2017 00:24:19 +0000</pubDate>
			<dc:creator>rehmanali1994</dc:creator>
			<guid isPermaLink="false">6059@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear All,&#60;/p&#62;
&#60;p&#62;I am having trouble with sensor element directivity in k-wave. In particular I am unable to get figure-of-eight (cos(theta)) directionality to work in problems that are more general than the &#34;Sensor Element Directivity in 2D Example&#34;. In my case I am trying to observe the cos(theta) rolloff when all sensors have a directivity angle of zero and they are receiving a signal from a point source (instead of receiving a plane wave). Please run and take a look at the code below to see the issue.&#60;/p&#62;
&#60;p&#62;Thank You,&#60;br /&#62;
Rehman Ali&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;% =========================================================================
% DEFINE THE GRID AND MEDIUM PROPERTIES
% =========================================================================

% create the computational grid
Nx = 128;        % number of grid points in the x (row) direction
Ny = 128;        % number of grid points in the y (column) direction
dx = 1e-3/Nx;   % grid point spacing in the x direction [m]
dy = dx;        % grid point spacing in the y direction [m]
kgrid = makeGrid(Nx, dx, Ny, dy);
x = (-(Nx-1)/2:(Nx-1)/2)*dx;
y = (-(Ny-1)/2:(Ny-1)/2)*dy;

% define the properties of the propagation medium
medium.sound_speed = 1500;  % [m/s]

% create the time array, then halve it to make the example end sooner
[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed);
kgrid.t_array = (0:0.7*length(kgrid.t_array))*dt;

% =========================================================================
% DEFINE THE DIRECTIONAL SENSOR ARRAY
% =========================================================================

% define a line of sensor points
sensor.mask = zeros(Nx,Ny);
depth_idx = 24;
lat_idx = 2:1:Ny-1;
sensor.mask(depth_idx, lat_idx) = 1;

% define the angle of max directivity for each sensor point:
%    0             = max sensitivity in x direction (up/down)
sensor.directivity_angle = zeros(Nx,Ny);

% define the directivity pattern
sensor.directivity_pattern = &#38;#39;gradient&#38;#39;; % Cosine-Based Directivity
%sensor.directivity_pattern = &#38;#39;pressure&#38;#39;; % Sinc-Based Directivity

% define the directivity size
sensor.directivity_size = 16*kgrid.dx;

% =========================================================================
% SIMULATION AND VISUALISATION FOR TIME-VARYING SOURCE PROBLEM
% =========================================================================

% define a time varying sinusoidal source (instead of an initial pressure)
source.p_mask = zeros(Nx,Ny);
source.p_mask(90, 64) = 1;
source.p0 = [];
source_freq = 12e6;
source_mag = 20.25;
source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array);

% run the simulation
input_args = {&#38;#39;PMLInside&#38;#39;, false, &#38;#39;PlotPML&#38;#39;, false, &#38;#39;PMLAlpha&#38;#39;, 2000};
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});

% plot the largest value of the output for each sensor
max_data = max(sensor_data(:, 150:end), [], 2);
figure, plot(y(lat_idx)&#38;#39;, max_data./max(max_data),&#38;#39;o&#38;#39;)
xlabel(&#38;#39;sensor lateral location (m)&#38;#39;)
ylabel(&#38;#39;maxima of single-element sensors&#38;#39;&#38;#39; outputs&#38;#39;)
axis([min(y) max(y) 0 1.05])&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
