sensor
I am having the problem of Error using .*
Matrix dimensions must agree.
Error in kspaceFirstOrder2D (line 740)
p = c.^2.*(rhox + rhoy);
Error in practice (line 57)
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor);%,input_args{:});
Here is my code
% define literals
clear all;close all
PML_X_SIZE = 20; % [grid points]
PML_Y_SIZE = 10; % [grid points]
% set total number of grid points not including the PML
Nx = 128 - 2*PML_X_SIZE; % [grid points]
Ny = 128 - 2*PML_Y_SIZE; % [grid points]
% set desired grid size in the x-direction not including the PML
x = 40e-3; % [m]
% calculate the spacing between the grid points
dx = x/Nx; % [m]
dy = dx; % [m]
% create the k-space grid
kgrid = makeGrid(Nx, dx, Ny, dy);
line_size = 80;
line_x_pos = 15;
line_y_pos = 5;
line_sound_speed = 3000;
water_sound_speed = 1500;
medium.density = 1000*ones(Nx, Ny); % [kg/m^3]
% create medium
medium.sound_speed = zeros(Ny, Nx);
medium.sound_speed(line_y_pos:line_y_pos + line_size - 1, ...
line_x_pos:line_x_pos + line_size - 1) ...
= diag(ones(1,line_size))+diag(ones(1,line_size-1),-1)+diag(ones(1,line_size-1),1);% look individually upon this part
% very important to find the difference. test size(diag(ones(1,52)))
% and diag(ones(1,51),-1)
medium.sound_speed(medium.sound_speed == 1) = line_sound_speed;
medium.sound_speed(medium.sound_speed == 0) = water_sound_speed;
% create the time array
t_end = 40e-6; % [s]
kgrid.t_array = makeTime(kgrid, medium.sound_speed, [], t_end);
source.p_mask = makeDisc(Nx, Ny, round(25e-3/dx), Ny/2, 3);
source_strength = 1e6; % [Pa]
input_freq = 0.5e6; % [Hz]
input_signal=sin(input_freq*2*pi*kgrid.t_array);
source.p = source_strength*input_signal;
source.p = filterTimeSeries(kgrid, medium, source.p);
sensor.mask = zeros(Nx, Ny);
sensor.mask(Nx/4, Ny/6) = 1;
sensor.record = {'p', 'p_final'};
display medium
figure;
imagesc(medium.sound_speed);
axis image;
colorbar;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor);%,input_args{:});
% display medium
%figure;
%imagesc(medium.sound_speed);
% axis image;
% colorbar;