Hello,

Thanks for the quick reply. I am working in 2D now.

I wasn't aware of the 'ReturnVelocity' option; it indeed gives a neat solution to my problem. This is what I considered directivity.

I have to dive a little deeper into the first thing you mention. Because it looks to me that the example which we both mentioned,

a) either does spatial averaging by enlarging the sensor element with `sensor.directivity_size`

on both sides, perpendicular to the directivity angle; and then averages over the enlarged sensor element. Or,

b) does not seem to be influenced much by the directivity settings.

Let me explain on the basis of how I used the example to come to these conclusions:

at the visualization part of the initial value problem, add the codelines:

```
% plot pressure distribution over time, sensed by individual elements
figure, plot(sensor_data(1:3:16,:)'); grid;
break;
```

which plots the pressure felt by 6 of the left elements (1 to 16). With `sensor.directivity_pattern = 'pressure';`

and

`sensor.directivity_size = 16*kgrid.dx;`

you can clearly see that the leftmost element sensed the pressure wave 16 pixels earlier than the center element. Which leads me to conclude point a)

Without setting `sensor.directivity_pattern`

and `sensor.directivity_size`

(just commenting them out) I would expect to see the same directivity as I did now via multiplying the velocity output with the directivity vector which I did like this:

`rx_signal = sensor_data.ux.*cos([(-1:1/15:1)*pi/2]') + sensor_data.uy.*sin([(-1:1/15:1)*pi/2]');`

Instead, in the example I get 6 times the pressure distribution of the initial pressure wave which are almost similar to each other.

Can you explain me with this example what ´a directivity pattern which is applied in k-space´ means?

____

In order to compare the two ideas of directivity I wanted to plot the systems next to each other. But somehow in this example I can't run kspaceFirstOrder2D with the 'ReturnVelocity' option when I haven't commented out the directivity entries.

I ended up with this:

```
% define the angle of max directivity for each single-element sensor
% 0 = max sensitivity in x direction (up/down)
% pi/2 or -pi/2 = max sensitivity in y direction (left/right)
%sensor.directivity_angle = zeros(Nx,Ny);
%sensor.directivity_angle(24,2:2:63) = (-1:1/15:1)*pi/2;
% define the directivity pattern
%sensor.directivity_pattern = 'pressure';
% define the directivity size
%sensor.directivity_size = 16*kgrid.dx;
% =========================================================================
% SIMULATION AND VISUALISATION FOR AN INITIAL VALUE PROBLEM
% =========================================================================
% define the initial pressure distribution
source.p0 = zeros(Nx,Ny);
source.p0(39:41,:) = 2;
% run the simulation
[sensor_data, p_final] = kspaceFirstOrder2D(kgrid, medium, source, sensor, 'PMLAlpha', [2 0], 'ReturnVelocity', true);
% calculate 'real' directivity
rx_signal = sensor_data.ux.*cos([(-1:1/15:1)*pi/2]') + sensor_data.uy.*sin([(-1:1/15:1)*pi/2]');
% plot pressure distribution over time, sensed by individual elements
figure;
%subplot(211); plot(sensor_data.p(1:3:16,:)'); grid; % doesn't work
subplot(212); plot(rx_signal(1:3:16,:)'); grid; title('real directivity');
break;
```