Hi, Thank you for letting me use the amazing toolbox.
I have a question.
Is it right that all I have to do for defining the attenuation parameters in the simulation is adding the following two codes after defining the sound speeds?
medium.alpha_coeff = 2; % [dB/(MHz^y cm)]
medium.alpha_power = 1.05;
Without the attenuation definition, the simulation works. However, once I defined the attenuation parameters, it doesn't work because of these errors.
----------------------------------------------------------------------------------
error : waitbar (line 100)
The second argument must be a message string or a handle to an existing waitbar.
error : kspaceFirstOrder2D (line 964)
waitbar(t_index / kgrid.Nt, pbar);
----------------------------------------------------------------------------------
How can I solve it?
Let me put my simulation code below.
Thank you in advance.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%My code%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Define sound speed at every grid points
sound_speed = 340; %[m/s] : base
medium.sound_speed = sound_speed * ones(Nx,Ny); % 340 [m/s]
medium.sound_speed = medium.sound_speed + BWI * 1200; % 1540[m/s]
medium.sound_speed = medium.sound_speed + BWI1 * 102; % 1567[m/s]
medium.sound_speed = medium.sound_speed + BWI2 * 147; % 1612[m/s]
medium.sound_speed = medium.sound_speed + BWI3 * 147; % 1612[m/s]
medium.sound_speed = medium.sound_speed + BWI4 * 125; % 1590[m/s]
medium.sound_speed = medium.sound_speed + BWI5 * 35; % 1500[m/s]
medium.sound_speed = medium.sound_speed + BWI6 * 119; % 1584[m/s]
medium.sound_speed = medium.sound_speed + BWI7 * 119; % 1584[m/s]
medium.sound_speed = medium.sound_speed + BWI8 * 35; % 1575[m/s]
medium.sound_speed = medium.sound_speed - BWI9 * 110; % 1465[m/s]
medium.sound_speed = medium.sound_speed + BWI10 * 2060; % 3635[m/s]
% medium.sound_speed = 1540 * ones(Nx,Ny);
% create a duplicate of the propagation medium structure and append the
% absorption properties
medium.sound_speed_ref = 1540; %[m/s]
medium.alpha_coeff = 2; % [dB/(MHz^y cm)]
medium.alpha_power = 1.05;
% make time array
% t_end should be longer than Nx*dx/slowest_sound_speed
t_end = 4e-4; % [s]
cfl = 1540*10^(-7)/dx; % the basical sound speed is 1540 [m/s]
kgrid.makeTime(1540,cfl,t_end);
% Define 1050[kg/m^3] as density at every grid points
medium.density = 1050 * ones(Nx, Ny); % [kg/m^3]
% % send the pulse
smask = zeros(Nx,Ny);
% cordination of the source
source_x = 0.0003; %[m]
source_y = -0.0096; %[m]
% % in case the number of grid points is odd
source_grid_x = round(Nx/2 + source_cordination_x/dx);
source_grid_y = round(Ny/2 + source_cordination_y/dy);
source_cordination_x = kgrid.x(source_grid_x,source_grid_y);
source_cordination_y = kgrid.y(source_grid_x,source_grid_y);
smask(source_grid_x,source_grid_y) = 1;
source.p_mask = smask;
source_strength = 10; % [Pa]
tone_burst_freq = 1e6; % [Hz]
tone_burst_cycles = 5;
sampling_freq = 1/kgrid.dt;
toneBurst(sampling_freq, tone_burst_freq, tone_burst_cycles, 'Plot', true);
% create the input signal using toneBurst
source.p = source_strength .* toneBurst(sampling_freq, tone_burst_freq, tone_burst_cycles);
source_capsule = source.p;
[max_source,index_source] = max(source.p);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Define the sensor
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Edge = imread('Edge.jpg');
sp = Edge;
[row,col,v] = find(sp);
tx = kgrid.x(row,col);
ty = kgrid.y(row,col);
transx = tx(:,1);
transy = ty(1,:);
number_of_elements = size(v,1);
% define a centered circular sensor
sensor.mask = sp;
% run the simulation with optional inputs for plotting the simulation
% layout in addition to removing the PML from the display
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, ...
'PlotLayout', true, 'PlotPML', false, 'RecordMovie',true,'PlotSim',true,'DataCast','gpuArray-single');
sensor_data = gather(sensor_data);
Saya Mizutani