k-Wave Toolbox |
![]() ![]() |
On this page… |
---|
This example provides a simple demonstration of using k-Wave for the simulation and detection of a time varying pressure source within a two-dimensional homogeneous propagation medium. It builds on the Homogeneous Propagation Medium Example.
A time varying pressure source is defined by assigning a binary matrix (i.e., a matrix of 1's and 0's
with the same dimensions as the computational grid) to source.p_mask
where the
1's represent the pixels that form part of the source. The time varying input signal is then
assigned to source.p
. This must be the same length as kgrid.t_array
and can be a single time series
(in which case it is applied to all source elements), or a matrix of time series following
the source elements using MATLAB's standard column-wise linear matrix index ordering.
In this example a sinusoidal input is assigned to a single source element to create an acoustic monopole. The remaining input structures are defined in the same way as in previous examples. Note, to avoid numerical
stabilities, the input should first be filtered using filterTimeSeries
(see the Filtering A Delta Function Input Signal Example
for more information).
% define a single source element source.p_mask = zeros(Nz, Nx); source.p_mask(end - Nz/4, Nx/2) = 1; % define a time varying sinusoidal source source_freq = 0.25e6; source_mag = 2; source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array); % smooth the source source.p = filterTimeSeries(kgrid, medium, source.p);
The simulation is again invoked by calling kspaceFirstOrder2D
.
A plot of the input time series driving the source element along with the acoustic pressure recorded at the sensor element is given below.
The final pressure field within the computational domain can also be returned by assigning both the sensor_data
and field_data
output fields.
% run the simulation [sensor_data, field_data] = kspaceFirstOrder2D(kgrid, medium, source, sensor);
![]() |
Time Varying Source Problems | Dipole Point Source In A Homogeneous Propagation Medium | ![]() |
© 2009, 2010, 2011 Bradley Treeby and Ben Cox.