Hey there,

I modified the steering the linear array example to have all elements fire at the appropriate times in order to meet at some desired focus. However, to get it to work, I had to apply a mock signal for a set amount of time, as I was not using the toneBurst function. I was wondering what units the tone_burst_offset is, so that I can't apply a similar concept to my function and get waveforms representative of actual acoustic sources. My code is shown below:

% =========================================================================

% SIMULATION

% =========================================================================

clear all

close all

% create the computational grid

Nx = 216; % number of grid points in the x (row) direction

Ny = Nx; % number of grid points in the y (column) direction

dx = 50e-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);

% define the properties of the propagation medium

medium.sound_speed = 1500; % [m/s]

medium.alpha_power = 1.5; % [dB/(MHz^y cm)]

medium.alpha_coeff = 0.75; % [dB/(MHz^y cm)]

medium.density = 1;

% create the time array

[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed);

kgrid.t_array = 0:dt:1000*dt;

% define sensor for entire grid

sensor.mask = zeros(Nx, Ny);

sensor.mask = ones(size(sensor.mask));

% define source mask for a linear transducer

num_elements = 216; % [grid points]

x_offset = 10; % [grid points]

source.p_mask = zeros(Nx, Ny);

start_index = Ny/2 - round(num_elements/2) + 1;

source.p_mask(x_offset, start_index:start_index + num_elements - 1) = 1;

% define the properties of the tone burst used to drive the transducer

sampling_freq = 1/dt; % [Hz]

steering_angle = 0; % [deg]

element_spacing = dx; % [m]

tone_burst_freq = 12e6; % [Hz]

tone_burst_cycles = 10;

% finds x and y positions of the elements

[x_pos,y_pos] = ind2sub([Nx,Ny],find(source.p_mask == 1));

% define x and y position of the desired focus location

x_focus = 120;

y_focus = Nx/2;

% calculate distances between elements and focus location

dists = sqrt((x_focus - x_pos).^2 + (y_focus - y_pos).^2);

% calculate number of actual steps

steps = dists.*kgrid.dx;

% calculate the times

times = steps./medium.sound_speed;

% calculate the actual time steps

timesteps = round(times./kgrid.dt);

% calculate time delays

istarts = round(max(timesteps)+1-timesteps);

% signal = toneBurstCopy(sampling_freq, tone_burst_freq, tone_burst_cycles);

for ii = 1:num_elements

source.p(ii,istarts(ii):istarts(ii)+3) = 5*sin(2*pi*tone_burst_freq*dt);

end

input_args = {'DisplayMask', source.p_mask};

% run the simulation

sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});

% =========================================================================

% VISUALISATION

% =========================================================================

% plot the input time series

figure;

num_source_time_points = length(source.p(1,:));

[t_sc, scale, prefix] = scaleSI(kgrid.t_array(num_source_time_points));

stackedPlot(kgrid.t_array(1:num_source_time_points)*scale, source.p);

xlabel(['Time [' prefix 's]']);

ylabel('Input Signals');

% reshaping of sensor_data to show acoustic field and focus point

size_sensor_data = size(sensor_data);

dimx = sqrt(size_sensor_data(1));

dimy = dimx;

dimz = size_sensor_data(2);

tmp = reshape(sensor_data,dimx,dimy,dimz);

tmp2 = max(tmp,[],3);

figure

imagesc(tmp2)