Hi Ben,
Any suggestions for the above problem?? What actually i am trying to explore is that when a source at let say 19mm away from the detector propagates a signal in a particular frequency. I need to check the frequency of the signals being captured by the detector placed 19mm away like whether it is the same frequency of the signals that was being propagated? Or how much is the loss??
I have pasted the MATLAB code below and it would be really very helpful if u can help me.
clear all;
close all;
clc;
% =========================================================================
% SIMULATION
% =========================================================================
% create the computational grid
Nx = 320; % number of grid points in the x direction
Ny = 320; % number of grid points in the y direction
Nz = 320; % number of grid points in the z direction
dx = 6.52e-5; % grid point spacing in the x direction [m]
dy = dx; % grid point spacing in the y direction [m]
dz = dx; % grid point spacing in the z direction [m]
kgrid = makeGrid(Nx, dx, Ny, dy, Nz, dz);
% define the properties of the propagation medium
medium.sound_speed = 1500; % [m/s]
%medium.sound_speed(1:Nx/2, :) = 1800; % [m/s]
%medium.density = 1000*ones(Nx, Ny, Nz); % [kg/m^3]
%medium.density(:, Ny/4:end) = 1200; % [kg/m^3]
% create the time array
[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed);
Nt = length(kgrid.t_array);
% create a concave sensor
sphere_sz = 194;
sphere_radius = 96;
sphere = makeSphere(sphere_sz, sphere_sz, sphere_sz, sphere_radius);
% carve most of the sphere off then add it to a mask of the correct size
sphere(:,98:end,:) = 0;
sensor.mask = zeros(Nx, Ny, Nz);
sphere_offset = 11;
sensor.mask(Nx/20:Nx/20+sphere_sz-1, Ny/20:Ny/20+sphere_sz-1, sphere_offset:sphere_offset+sphere_sz-1) = sphere;
% define a time varying sinusoidal source
source_freq = 10e6;
source_mag = 10;
source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array);
source.p = filterTimeSeries(kgrid, medium, source.p);
% place the first point source near the focus of the detector
source1 = zeros(Nx, Ny, Nz);
source1(112, 306, 108) = 1;
% place the second point source off axis
%source2 = zeros(Nx, Ny, Nz);
%source2(Nx/2-10, Ny/2, sphere_offset+sphere_radius) = 1;
% run the first simulation
source.p_mask = source1;
input_args = {'PMLSize', 10, 'DataCast', 'single', 'PlotSim', false};
sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});
% average the data recorded at each grid point to simulate the measured
% signal from a single element focussed detector
sensor_data = sum(sensor_data, 1);
% run the second simulation
%source.p_mask = source2;
%sensor_data2 = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});
% average the data recorded at each grid point to simulate the measured
% signal from a single element focussed detector
%sensor_data2 = sum(sensor_data2, 1);
% run the simulation
%sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor);
% define the frequency response of the sensor elements
center_freq = 10e6; % [Hz]
bandwidth = 10; % [%]
sensor.frequency_response = [center_freq, bandwidth];
% re-run the simulation
sensor_data_filtered = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});
% calculate the frequency spectrum at the first sensor element
[f, sensor_data_as] = spectrum(sensor_data(1, :), 1/dt);
[f, sensor_data_filtered_as] = spectrum(sensor_data_filtered(1, :), 1/dt);
% =========================================================================
% VISUALISATION
% =========================================================================
% plot the detector and on-axis and off-axis point sources
voxelPlot(sensor.mask + source1);
view([14, 20]);
% plot the time series corresponding to the on-axis and off-axis sources
figure
[t_sc, t_scale, t_prefix] = scaleSI(kgrid.t_array(end));
plot(kgrid.t_array.*t_scale, sensor_data, '-');
hold on
%plot(kgrid.t_array.*t_scale, sensor_data2, 'r-');
xlabel(['Time [' t_prefix 's]']);
ylabel('Average Pressure Measured By Focussed Detector [au]');
legend('Source on axis', 'Source off axis');
figure;
[t_sc, scale, prefix] = scaleSI(max(kgrid.t_array(:)));
plot(scale*kgrid.t_array, sensor_data(1, :), 'k-', scale*kgrid.t_array, sensor_data_filtered(1, :), 'r-');
ylabel('Pressure [au]');
xlabel(['Time [' prefix 's]']);
legend('Original Time Series', 'Filtered Time Series');
% plot the amplitude spectrum
figure;
[f_sc, scale, prefix] = scaleSI(max(f(:)));
plot(scale*f, sensor_data_as, 'k-', scale*f, sensor_data_filtered_as, 'r-');
ylabel('Amplitude Spectrum');
xlabel(['Frequency [' prefix 'Hz]']);
legend('Original Time Series', 'Filtered Time Series');
set(gca, 'XLim', [0 30]);
Thanks,
Eldhose