<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>k-Wave User Forum &#187; User Favorites: shak360</title>
		<link><a href='http://www.k-wave.org/forum/profile/shak360'>shak360</a></link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:00:02 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.k-wave.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.k-wave.org/forum/rss/profile/" rel="self" type="application/rss+xml" />

		<item>
			<title>Jiri Jaros on "`Fatal error: Could not write into &#34;&#34; dataset.: iostream stream error`"</title>
			<link>http://www.k-wave.org/forum/topic/fatal-error-could-not-write-into-dataset-iostream-stream-error#post-8792</link>
			<pubDate>Tue, 06 Jun 2023 12:51:25 +0000</pubDate>
			<dc:creator>Jiri Jaros</dc:creator>
			<guid isPermaLink="false">8792@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;It is the problem of HDF5 incompatibility in new Matlab versions, we released a fix in version v1.4 that saves HDF5Atributes using system encoding.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>subhadip627@ on "`Fatal error: Could not write into &#34;&#34; dataset.: iostream stream error`"</title>
			<link>http://www.k-wave.org/forum/topic/fatal-error-could-not-write-into-dataset-iostream-stream-error#post-8715</link>
			<pubDate>Wed, 08 Mar 2023 07:28:57 +0000</pubDate>
			<dc:creator>subhadip627@</dc:creator>
			<guid isPermaLink="false">8715@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi&#60;br /&#62;
 I am facing a compilation problem with the following code, i can't understand the solution as i am a new user for cpp code.&#60;/p&#62;
&#60;p&#62;clear all&#60;br /&#62;
run([getkWavePath 'private/getH5Literals']);&#60;br /&#62;
  filename = 'input12.h5';&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
Nx = 64;            % number of grid points in the x direction&#60;br /&#62;
Ny = 64;            % number of grid points in the y direction&#60;br /&#62;
Nz = 64;            % number of grid points in the z direction&#60;br /&#62;
dx = 0.1e-3;        % grid point spacing in the x direction [m]&#60;br /&#62;
dy = 0.1e-3;        % grid point spacing in the y direction [m]&#60;br /&#62;
dz = 0.1e-3;        % grid point spacing in the z direction [m]&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dy, Nz, dz);&#60;/p&#62;
&#60;p&#62;% define the properties of the propagation medium&#60;br /&#62;
medium.sound_speed = 1500 * ones(Nx, Ny, Nz);	% [m/s]&#60;br /&#62;
% medium.sound_speed(1:Nx/2, :, :) = 1800;        % [m/s]&#60;br /&#62;
medium.density = 1000 * ones(Nx, Ny, Nz);       % [kg/m^3]&#60;br /&#62;
% medium.density(:, Ny/4:end, :) = 1200;          % [kg/m^3]&#60;br /&#62;
c0=medium.sound_speed;&#60;br /&#62;
% make sure the input is in the correct data format&#60;br /&#62;
eval(['c0 = ' MATRIX_DATA_TYPE_MATLAB '(c0);']);&#60;/p&#62;
&#60;p&#62;% save the sound speed matrix&#60;br /&#62;
writeMatrix([filename], c0, 'c0');&#60;br /&#62;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;br /&#62;
% % % % create initial pressure distribution using makeBall&#60;br /&#62;
ball_magnitude = 10;    % [Pa]&#60;br /&#62;
ball_x_pos = 38;        % [grid points]&#60;br /&#62;
ball_y_pos = 32;        % [grid points]&#60;br /&#62;
ball_z_pos = 32;        % [grid points]&#60;br /&#62;
ball_radius = 5;        % [grid points]&#60;br /&#62;
p_mask =  makeBall(Nx, Ny, Nz, ball_x_pos, ball_y_pos, ball_z_pos, ball_radius);&#60;br /&#62;
ball_1 = ball_magnitude *p_mask ;&#60;/p&#62;
&#60;p&#62;source.p0 = ball_1;&#60;br /&#62;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;br /&#62;
% define a square source mask facing in the x-direction using the&#60;br /&#62;
% find linear source indices&#60;br /&#62;
p_source_index = find(p_mask == 1);&#60;br /&#62;
p_source_index = reshape(p_source_index, [], 1);&#60;/p&#62;
&#60;p&#62;% make sure the input is in the correct data format&#60;br /&#62;
eval(['p_source_index = ' INTEGER_DATA_TYPE_MATLAB '(p_source_index);']);&#60;br /&#62;
% save the source index matrix&#60;br /&#62;
writeMatrix([filename], p_source_index, 'p_source_index');&#60;/p&#62;
&#60;p&#62;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;br /&#62;
% cast matrix to single precision&#60;br /&#62;
eval(['ball_1 = ' MATRIX_DATA_TYPE_MATLAB '(ball_1);']);&#60;br /&#62;
% save the input signal&#60;br /&#62;
writeMatrix([filename], ball_1, 'ball_1');&#60;br /&#62;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;br /&#62;
% define a sensor mask through the central plane&#60;br /&#62;
sensor_mask = false(Nx, Ny, Nz);&#60;br /&#62;
sensor_mask(:, :, Nz/2) = 1;&#60;/p&#62;
&#60;p&#62;% extract the indices of the active sensor mask elements&#60;br /&#62;
sensor_mask_index = find(sensor_mask);&#60;br /&#62;
sensor_mask_index = reshape(sensor_mask_index, [], 1);&#60;/p&#62;
&#60;p&#62;% make sure the input is in the correct data format&#60;br /&#62;
eval(['sensor_mask_index = ' INTEGER_DATA_TYPE_MATLAB '(sensor_mask_index);']);&#60;br /&#62;
sensor.mask=sensor_mask;&#60;br /&#62;
% save the sensor mask&#60;br /&#62;
writeMatrix([filename], sensor_mask_index, 'sensor_mask_index');&#60;br /&#62;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;br /&#62;
% write grid parameters&#60;br /&#62;
writeGrid([filename], [Nx, Ny, Nz], [dx, dy, dz], ...&#60;br /&#62;
    [10, 10, 10], [10, 10,10], ...&#60;br /&#62;
    Nt, dt, 1500);&#60;/p&#62;
&#60;p&#62;% write flags&#60;br /&#62;
writeFlags([filename]);&#60;/p&#62;
&#60;p&#62;% set additional file attributes&#60;br /&#62;
writeAttributes([filename]);&#60;/p&#62;
&#60;p&#62;kspaceFirstOrder3D(kgrid, medium, source, sensor, 'SaveToDisk', filename);&#60;br /&#62;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;/p&#62;
&#60;p&#62;here i am able to make .h5 file but while compiling the .h5 file with kspaceFirstOrder-OMP&#60;/p&#62;
&#60;p&#62;i got ----&#60;/p&#62;
&#60;p&#62;+---------------------------------------------------------------+&#60;br /&#62;
&#124;                   kspaceFirstOrder-OMP v1.3                   &#124;&#60;br /&#62;
+---------------------------------------------------------------+&#60;br /&#62;
&#124; Reading simulation configuration:                      Failed &#124;&#60;br /&#62;
+---------------------------------------------------------------+&#60;br /&#62;
+---------------------------------------------------------------+&#60;br /&#62;
&#124;            !!! K-Wave experienced a fatal error !!!           &#124;&#60;br /&#62;
+---------------------------------------------------------------+&#60;br /&#62;
&#124; Error: Invalid format of the input file: iostream stream      &#124;&#60;br /&#62;
&#124;        error                                                  &#124;&#60;br /&#62;
+---------------------------------------------------------------+&#60;br /&#62;
&#124;                      Execution terminated                     &#124;&#60;br /&#62;
+---------------------------------------------------------------+
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Jiri Jaros on "`Fatal error: Could not write into &#34;&#34; dataset.: iostream stream error`"</title>
			<link>http://www.k-wave.org/forum/topic/fatal-error-could-not-write-into-dataset-iostream-stream-error#post-6813</link>
			<pubDate>Fri, 29 Mar 2019 09:35:49 +0000</pubDate>
			<dc:creator>Jiri Jaros</dc:creator>
			<guid isPermaLink="false">6813@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi shak360,&#60;/p&#62;
&#60;p&#62;1. I will send you the codes with a readme via email.&#60;br /&#62;
2. You can see a detail log using a parameter --verbose 2&#60;br /&#62;
3. The execution time is inversely proportional to the number of cores. Typically, when you double the number of cores, you decrease the simulation time by a factor of 1.6. But keep in mind, the highest number of cores used is limited by Nz and Ny (precisely by the highest common denominator). With 1024 cores you can get down to 2 days.&#60;/p&#62;
&#60;p&#62;Best&#60;br /&#62;
Jiri
&#60;/p&#62;</description>
		</item>
		<item>
			<title>shak360 on "`Fatal error: Could not write into &#34;&#34; dataset.: iostream stream error`"</title>
			<link>http://www.k-wave.org/forum/topic/fatal-error-could-not-write-into-dataset-iostream-stream-error#post-6808</link>
			<pubDate>Thu, 28 Mar 2019 17:47:09 +0000</pubDate>
			<dc:creator>shak360</dc:creator>
			<guid isPermaLink="false">6808@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;(The above post should say 690 kHz not 690  Hz.)&#60;/p&#62;
&#60;p&#62;Sorry, but I just wanted to add this briefly:&#60;/p&#62;
&#60;p&#62;In this paper: &#60;a href=&#34;https://asa.scitation.org/doi/pdf/10.1121/1.4976339?class=pdf&#34; rel=&#34;nofollow&#34;&#62;https://asa.scitation.org/doi/pdf/10.1121/1.4976339?class=pdf&#60;/a&#62;, the following specs were used for &#34;3D simulations [on head models at 500 kHz]:&#60;br /&#62;
 - on the IT4I Salomon supercomputing cluster.&#60;br /&#62;
 - Each simulation was carried out on Intel Xeon E5-4627v2, 3.3 GHz, 8 cores and&#60;br /&#62;
 - 256 GB of RAM per simulation. &#60;/p&#62;
&#60;p&#62;The largest 3D simulations had a domain size of 1024^3 including the PML and comprised 22,718 time steps, with a total runtime of 112.3 hours (or ~5 days).&#34; &#60;/p&#62;
&#60;p&#62;This is similar to what I'm trying to do. Granted this was most likely the longest simulation you had to test, how feasible was it when you tried to simulate this? I'm just concerned because, what would you do in the scenario where you wanted to change one aspect of the simulation (such as the placement or the orientation of the transducer, or some simulation parameters), but you would have to wait ~5 days to reconfigure?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>shak360 on "`Fatal error: Could not write into &#34;&#34; dataset.: iostream stream error`"</title>
			<link>http://www.k-wave.org/forum/topic/fatal-error-could-not-write-into-dataset-iostream-stream-error#post-6807</link>
			<pubDate>Thu, 28 Mar 2019 17:08:47 +0000</pubDate>
			<dc:creator>shak360</dc:creator>
			<guid isPermaLink="false">6807@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Dr. Jaros,&#60;/p&#62;
&#60;p&#62;Thanks for the quick reply. I see, so even storing the entire field can lead to issues with memory (I'm assuming the other 30 matrices are similar to the ones like &#60;code&#62;medium.density&#60;/code&#62; and &#60;code&#62;medium.sound_speed&#60;/code&#62;, which are why they would have to be the same size as the grid). I need the high resolution spatial grid, however, to sample my transducer frequency of 690 Hz accordingly. The smallest amount of time I want to run the simulation for is 5e-4 seconds, which is still relatively long. I'd appreciate if you send me the distributed simulation code because I do have access to a cluster, but I'm seeing now that I'll have to approach this problem differently.&#60;/p&#62;
&#60;p&#62;I'm trying to simulate ultrasound on head-models from CT scans, and low-resolution, short time-scale simulations are possible in 2D, but I want to be able to do more. I'm still relatively new to simulation and ultrasound in general but k-Wave has helped me a lot; do you have any advice on how to move forward? &#60;/p&#62;
&#60;p&#62;Also, where I can find the whole simulation log?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Jiri Jaros on "`Fatal error: Could not write into &#34;&#34; dataset.: iostream stream error`"</title>
			<link>http://www.k-wave.org/forum/topic/fatal-error-could-not-write-into-dataset-iostream-stream-error#post-6769</link>
			<pubDate>Fri, 15 Mar 2019 13:55:57 +0000</pubDate>
			<dc:creator>Jiri Jaros</dc:creator>
			<guid isPermaLink="false">6769@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi shak360,&#60;br /&#62;
Could you please send me the whole simulation log and what machine specs. &#60;/p&#62;
&#60;p&#62;This simple calculation indicates it is a memory problem.&#60;br /&#62;
If the simulation is absorbing, nonlinear and heterogeneous, you need about 30 matrices of the grid size. In this case 1024*1024*512 points x 4B = 60GB of memory. There's no GPU on the market able to running this simulation and a sever with 64GB of RAM could go into troubles with swapping. &#60;/p&#62;
&#60;p&#62;Storing the whole field rises up another problem - One time step of pressure consumes 2GB. Sampling even 512 time steps takes 1TB of data - opening this dataset in matlab at once is virtually impossible.&#60;/p&#62;
&#60;p&#62;There's not much we can do about it. I'd definitely reduce the area you're sampling as well as the number of time steps.&#60;/p&#62;
&#60;p&#62;If you had access to a distributed cluster/supercomputer, we could send you a prototype of the distributed simulation code. But keep in mind, at least 256 CPU cores would be necessary and the simulation output can easily become intractable.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>shak360 on "`Fatal error: Could not write into &#34;&#34; dataset.: iostream stream error`"</title>
			<link>http://www.k-wave.org/forum/topic/fatal-error-could-not-write-into-dataset-iostream-stream-error#post-6766</link>
			<pubDate>Fri, 08 Mar 2019 22:17:42 +0000</pubDate>
			<dc:creator>shak360</dc:creator>
			<guid isPermaLink="false">6766@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I'm trying to use the C++ 3D simulations after running into some memory errors using the MATLAB version. I received the error:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;Fatal error: Could not write into &#38;quot;&#38;quot; dataset.: iostream stream error&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;I'm pretty sure I have everything set up right, though... Is this a memory issue? I'm asking it to sense the entire field:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;sensor.mask = [1, 1, 1, Nx, Ny, Nz].&#38;#39;;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Is this not a good way of going about that? I've spent a lot of time with k-Wave so intuitively I think some options would be to reduce that &#60;code&#62;sensor.mask&#60;/code&#62; to some volume (or maybe even 2D area) around the focus and only record a certain portion of time at steady-state. Is this correct? Would this help with any memory issues? Is it reasonable to measure one or two periods before the end of the simulation as input to &#60;code&#62;sensor.record_start_index&#60;/code&#62;? I have a GPU and I managed to get both the CUDA (MATLAB) and CUDA (C++) modules that you have supplied also working, but I'm running into GPU memory issues there as well. I don't think I can make any more changes to the grid size or the domain dimensions (1024 x 1024 x 512) (0.243 mm x 0.243 mm x 0.25 mm) as I want to be able to support a frequency of 690kHz.&#60;/p&#62;
&#60;p&#62;Thank you in advance for the help. k-Wave is an excellent tool.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Source Positioning"</title>
			<link>http://www.k-wave.org/forum/topic/source-positioning#post-6420</link>
			<pubDate>Wed, 18 Apr 2018 09:19:53 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6420@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi cahyakirana,&#60;/p&#62;
&#60;p&#62;If you're running simulations in 2D, take a look at the &#60;code&#62;makeMultiArc&#60;/code&#62; function, it should do what you need.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>cahyakirana on "Source Positioning"</title>
			<link>http://www.k-wave.org/forum/topic/source-positioning#post-6406</link>
			<pubDate>Wed, 11 Apr 2018 11:46:37 +0000</pubDate>
			<dc:creator>cahyakirana</dc:creator>
			<guid isPermaLink="false">6406@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;hello,&#60;/p&#62;
&#60;p&#62;i'm super new to this toolbox, and i need to simulate 20 transducers to see the field pattern based on the transducers' configuration (e.g 5 x 4 arrays or bee-hive configuration). how can i assign the position of each transducer? thank you.&#60;/p&#62;
&#60;p&#62;% Simulating Transducer Field Patterns Example&#60;br /&#62;
%&#60;br /&#62;
% This example demonstrates the use of k-Wave to compute the field pattern&#60;br /&#62;
% generated by a curved single element transducer in two dimensions. It&#60;br /&#62;
% builds on the Monopole Point Source In A Homogeneous Propagation Medium&#60;br /&#62;
% Example.&#60;br /&#62;
%&#60;br /&#62;
% author: Bradley Treeby&#60;br /&#62;
% date: 10th December 2009&#60;br /&#62;
% last update: 4th May 2017&#60;br /&#62;
%&#60;br /&#62;
% This function is part of the k-Wave Toolbox (&#60;a href=&#34;http://www.k-wave.org&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org&#60;/a&#62;)&#60;br /&#62;
% Copyright (C) 2009-2017 Bradley Treeby&#60;/p&#62;
&#60;p&#62;% This file is part of k-Wave. k-Wave is free software: you can&#60;br /&#62;
% redistribute it and/or modify it under the terms of the GNU Lesser&#60;br /&#62;
% General Public License as published by the Free Software Foundation,&#60;br /&#62;
% either version 3 of the License, or (at your option) any later version.&#60;br /&#62;
%&#60;br /&#62;
% k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY&#60;br /&#62;
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS&#60;br /&#62;
% FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for&#60;br /&#62;
% more details.&#60;br /&#62;
%&#60;br /&#62;
% You should have received a copy of the GNU Lesser General Public License&#60;br /&#62;
% along with k-Wave. If not, see &#38;lt;http://www.gnu.org/licenses/&#38;gt;. &#60;/p&#62;
&#60;p&#62;clearvars;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
Nx = 216;           % number of grid points in the x (row) direction&#60;br /&#62;
Ny = 216;           % number of grid points in the y (column) direction&#60;br /&#62;
dx = 50e-3/Nx;    	% grid point spacing in the x direction [m]&#60;br /&#62;
dy = dx;            % grid point spacing in the y direction [m]&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dy);&#60;/p&#62;
&#60;p&#62;% define the properties of the propagation medium&#60;br /&#62;
medium.sound_speed = 1500;  % [m/s]&#60;br /&#62;
medium.alpha_coeff = 0.75;  % [dB/(MHz^y cm)]&#60;br /&#62;
medium.alpha_power = 1.5;&#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
kgrid.makeTime(medium.sound_speed);&#60;/p&#62;
&#60;p&#62;% define a curved transducer element&#60;br /&#62;
cx = ;&#60;br /&#62;
cy = ;&#60;br /&#62;
radius = 10;&#60;br /&#62;
source.p_mask = makeDisc(Nx, Ny, cx, cy, radius, 'true');&#60;/p&#62;
&#60;p&#62;% define a time varying sinusoidal source&#60;br /&#62;
source_freq = 0.25e6;       % [Hz]&#60;br /&#62;
source_mag = 0.5;           % [Pa]&#60;br /&#62;
source.p = source_mag * sin(2 * pi * source_freq * kgrid.t_array);&#60;/p&#62;
&#60;p&#62;% filter the source to remove high frequencies not supported by the grid&#60;br /&#62;
source.p = filterTimeSeries(kgrid, medium, source.p);&#60;/p&#62;
&#60;p&#62;% create a display mask to display the transducer&#60;br /&#62;
display_mask = source.p_mask;&#60;/p&#62;
&#60;p&#62;% create a sensor mask covering the entire computational domain using the&#60;br /&#62;
% opposing corners of a rectangle&#60;br /&#62;
sensor.mask = [1, 1, Nx, Ny].';&#60;/p&#62;
&#60;p&#62;% set the record mode capture the final wave-field and the statistics at&#60;br /&#62;
% each sensor point&#60;br /&#62;
sensor.record = {'p_final', 'p_max', 'p_rms'};&#60;/p&#62;
&#60;p&#62;% assign the input options&#60;br /&#62;
input_args = {'DisplayMask', display_mask, 'PMLInside', false, 'PlotPML', false};&#60;/p&#62;
&#60;p&#62;% run the simulation&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% add the source mask onto the recorded wave-field&#60;br /&#62;
sensor_data.p_final(source.p_mask ~= 0) = 1;&#60;br /&#62;
sensor_data.p_max(source.p_mask ~= 0) = 1;&#60;br /&#62;
sensor_data.p_rms(source.p_mask ~= 0) = 1;&#60;/p&#62;
&#60;p&#62;% plot the final wave-field&#60;br /&#62;
figure;&#60;br /&#62;
subplot(1, 3, 1);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, sensor_data.p_final, [-1 1]);&#60;br /&#62;
colormap(getColorMap);&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Final Wave Field');&#60;/p&#62;
&#60;p&#62;% plot the maximum recorded pressure&#60;br /&#62;
subplot(1, 3, 2);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, sensor_data.p_max, [-1 1]);&#60;br /&#62;
colormap(getColorMap);&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Maximum Pressure');&#60;/p&#62;
&#60;p&#62;% plot the rms recorded pressure&#60;br /&#62;
subplot(1, 3, 3);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, sensor_data.p_rms, [-1 1]);&#60;br /&#62;
colormap(getColorMap);&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('RMS Pressure');&#60;br /&#62;
scaleFig(2, 1);
&#60;/p&#62;</description>
		</item>
		<item>
			<title>NealXu on "sampling frequency and maximum supported frequency"</title>
			<link>http://www.k-wave.org/forum/topic/sampling-frequency-and-maximum-supported-frequency#post-6255</link>
			<pubDate>Wed, 10 Jan 2018 19:09:02 +0000</pubDate>
			<dc:creator>NealXu</dc:creator>
			<guid isPermaLink="false">6255@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi..as per my knowledge if you need to propagate higher frequencies, you can simply decrease your spatial grid step which will of course require more RAM and computational time but you can use the C versions of k-Wave or the GPU version if Matlab is too slow.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "sampling frequency and maximum supported frequency"</title>
			<link>http://www.k-wave.org/forum/topic/sampling-frequency-and-maximum-supported-frequency#post-5388</link>
			<pubDate>Tue, 16 Feb 2016 02:28:40 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">5388@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Prabodh,&#60;/p&#62;
&#60;p&#62;If you look at the Fourier spectrum of your recorded time signal, it won't contain any energy above the maximum frequency spatially supported on the grid (e.g., see the second figure in &#60;a href=&#34;http://www.k-wave.org/documentation/example_na_filtering.php&#34;&#62;this example&#60;/a&#62;). The time sampling is typically finer than the spatial sampling to meet stability requirements, i.e., c*dt &#38;lt; dx or CFL &#38;lt; 1. You can read more about this in the k-Wave manual if you would like more details. You will also encounter this situation in experimental data, where the temporal sampling frequency is often much higher than the maximum frequency in your data.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>prabodh_iitk on "sampling frequency and maximum supported frequency"</title>
			<link>http://www.k-wave.org/forum/topic/sampling-frequency-and-maximum-supported-frequency#post-5379</link>
			<pubDate>Thu, 04 Feb 2016 06:44:47 +0000</pubDate>
			<dc:creator>prabodh_iitk</dc:creator>
			<guid isPermaLink="false">5379@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear Anthony,&#60;/p&#62;
&#60;p&#62;Thank you for your response. My major concern lies in the fact that if I take the Fourier spectra of the photoacoustic signal, It will have the frequency amplitudes corresponding to the sampling frequency that is ~ 60MHz. While the maximum supported frequency is 7.5 MHz. So I wish to know what the significance of the amplitudes corresponding to the frequencies greater than 7.5MHz are.&#60;/p&#62;
&#60;p&#62;Thank you&#60;/p&#62;
&#60;p&#62;--&#60;br /&#62;
Regards&#60;br /&#62;
Prabodh
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anthony on "sampling frequency and maximum supported frequency"</title>
			<link>http://www.k-wave.org/forum/topic/sampling-frequency-and-maximum-supported-frequency#post-5376</link>
			<pubDate>Wed, 03 Feb 2016 17:22:07 +0000</pubDate>
			<dc:creator>Anthony</dc:creator>
			<guid isPermaLink="false">5376@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Prabodh,&#60;/p&#62;
&#60;p&#62;The maximum supported frequency is computed based on the spatial grid step because you need at least two grid points per wavelength (Shannon-Nyquist theorem): see the user guide for more details.&#60;/p&#62;
&#60;p&#62;Therefore, if you need to propagate higher frequencies, you can simply decrease your spatial grid step (which will of course require more RAM and computational time but you can use the C versions of k-Wave or the GPU version if Matlab is too slow).&#60;/p&#62;
&#60;p&#62;Best regards,&#60;br /&#62;
Anthony&#60;/p&#62;
&#60;p&#62;PS : You probably have a medium with a 1500m/s sound speed which gives you a wavelength of 0.2e-3m at 7.5 MHz, which corresponds to 2 points per wavelength.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>prabodh_iitk on "sampling frequency and maximum supported frequency"</title>
			<link>http://www.k-wave.org/forum/topic/sampling-frequency-and-maximum-supported-frequency#post-5375</link>
			<pubDate>Wed, 03 Feb 2016 08:18:13 +0000</pubDate>
			<dc:creator>prabodh_iitk</dc:creator>
			<guid isPermaLink="false">5375@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear Sir,&#60;/p&#62;
&#60;p&#62;I was running example_IVP_3D_simulation.m code with :&#60;br /&#62;
% create the computational grid&#60;br /&#62;
Nx = 64;            % number of grid points in the x direction&#60;br /&#62;
Ny = 64;            % number of grid points in the y direction&#60;br /&#62;
Nz = 64;            % number of grid points in the z direction&#60;br /&#62;
dx = 0.1e-3;        % grid point spacing in the x direction [m]&#60;br /&#62;
dy = 0.1e-3;        % grid point spacing in the y direction [m]&#60;br /&#62;
dz = 0.1e-3;        % grid point spacing in the z direction [m]&#60;/p&#62;
&#60;p&#62;*****************************&#60;br /&#62;
Running k-Wave simulation...&#60;br /&#62;
  start time: 03-Feb-2016 12:20:30&#60;br /&#62;
  reference sound speed: 1800m/s&#60;br /&#62;
  dt: 16.6667ns, t_end: 7.3833us, time steps: 444&#60;br /&#62;
  input grid size: 64 by 64 by 64 grid points (6.4 by 6.4 by 6.4mm)&#60;br /&#62;
  maximum supported frequency: 7.5MHz&#60;/p&#62;
&#60;p&#62;Here maximum supported frequency is 7.5MHz while the sampling frequency is ~ 60 MHz.&#60;/p&#62;
&#60;p&#62;I wish to know what is the meaning for maximum supported frequency? &#60;/p&#62;
&#60;p&#62;Does this mean that we need to filter out all the frequencies &#38;gt; 7.5MHz from the simulated photoacoustic signal?  &#60;/p&#62;
&#60;p&#62;Thank you.&#60;/p&#62;
&#60;p&#62;--&#60;br /&#62;
Regards&#60;br /&#62;
Prabodh
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Source Positioning"</title>
			<link>http://www.k-wave.org/forum/topic/source-positioning#post-4891</link>
			<pubDate>Fri, 12 Dec 2014 12:02:18 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">4891@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi gondolio,&#60;/p&#62;
&#60;p&#62;If you don't want to focus the field, just remove the line of code that calls the &#60;code&#62;focus&#60;/code&#62; function, and instead assign the &#60;code&#62;input_signal&#60;/code&#62; directly to &#60;code&#62;source.p&#60;/code&#62;. This will then drive the source aperture with the same signal, without any beamforming delays.&#60;/p&#62;
&#60;p&#62;The parameters &#60;code&#62;medium.alpha_coeff&#60;/code&#62; (a0) and &#60;code&#62;medium.alpha_power&#60;/code&#62; (y) describe the power law acoustic attenuation in the medium, where the attenuation is of the form a = a0*f^y. The parameter &#60;code&#62;medium.BonA&#60;/code&#62; is the nonlinearity parameter.&#60;/p&#62;
&#60;p&#62;For water, these values are given by &#60;code&#62;medium.alpha_coeff = 2.17e-3&#60;/code&#62;, &#60;code&#62;medium.alpha_power = 2&#60;/code&#62;, &#60;code&#62;medium.BonA = 4.96&#60;/code&#62;. In water, at lower frequencies and amplitudes, the attenuation and nonlinearity will only have a small effect on the wave field. At higher frequencies and amplitudes, these effects become more important.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gondolio on "Source Positioning"</title>
			<link>http://www.k-wave.org/forum/topic/source-positioning#post-4876</link>
			<pubDate>Sat, 06 Dec 2014 03:58:58 +0000</pubDate>
			<dc:creator>gondolio</dc:creator>
			<guid isPermaLink="false">4876@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Bradley!&#60;/p&#62;
&#60;p&#62;Thank you. That is what I ended up doing, however, I realized that the source I created is focused which I do not want.&#60;/p&#62;
&#60;p&#62;Currently, I am trying to create a source with a pulsed signal that has these parameters:&#60;br /&#62;
&#60;a href=&#34;http://imgur.com/SioqhAe&#34; rel=&#34;nofollow&#34;&#62;http://imgur.com/SioqhAe&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Which results in a beam pattern that looks like this when the medium is water:&#60;br /&#62;
&#60;a href=&#34;http://imgur.com/3aRLw7s&#34; rel=&#34;nofollow&#34;&#62;http://imgur.com/3aRLw7s&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I am attempting to accomplish this using the toneBurst function, but I am not having much luck.&#60;/p&#62;
&#60;p&#62;'% define properties of the input signal&#60;br /&#62;
source_strength = 0.076e6;          % [Pa]&#60;br /&#62;
tone_burst_freq = 1.5e6;    	% [Hz]&#60;br /&#62;
tone_burst_cycles = 32;&#60;/p&#62;
&#60;p&#62;% create the input signal using toneBurst&#60;br /&#62;
input_signal = toneBurst(1/kgrid.dt, tone_burst_freq, tone_burst_cycles,'Plot',true,'Envelope','Rectangular','SignalLength',(1/kgrid.dt)*200e-6);&#60;/p&#62;
&#60;p&#62;% scale the source magnitude by the source_strength divided by the&#60;br /&#62;
% impedance (the source is assigned to the particle velocity)&#60;br /&#62;
input_signal = (source_strength./(medium.sound_speed*medium.density)).*input_signal;'&#60;/p&#62;
&#60;p&#62;Do you have any suggestions? I apologize if this is a stupid question, I am very new to this material. Also, when defining the medium, what do medium.alpha_power and medium.BonA refer to and where could I find these values for water?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Source Positioning"</title>
			<link>http://www.k-wave.org/forum/topic/source-positioning#post-4872</link>
			<pubDate>Fri, 05 Dec 2014 17:59:25 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">4872@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;A first glance (without having run your code), it looks like your source and sensor are both defined in the x/y plane (facing in the z-dimension). If you want to see a beam profile, then you could try putting the sensor in the x/z plane, or defining your source to face in a different direction.&#60;/p&#62;
&#60;p&#62;Hope that helps,&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gondolio on "Source Positioning"</title>
			<link>http://www.k-wave.org/forum/topic/source-positioning#post-4863</link>
			<pubDate>Wed, 03 Dec 2014 06:40:58 +0000</pubDate>
			<dc:creator>gondolio</dc:creator>
			<guid isPermaLink="false">4863@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hey guys, I'm super new to this toolbox and have barely any idea what I'm doing, so bare with me. I am trying to model how ultrasound waves from a single element,circular transducer propagate through skin, tissue, and bone. I originally tried using the makeTransducer function, however, as I've seen from other posts, there are better ways of modeling this. So I am currently using the method where you create a circular source. I think I am having trouble positioning this source so that it resembles the beam patterns created by transducer as in the example_us_beam_patterns file. &#60;/p&#62;
&#60;p&#62;This is what I want it to look like: &#60;a href=&#34;http://imgur.com/NQxiXax&#34; rel=&#34;nofollow&#34;&#62;http://imgur.com/NQxiXax&#60;/a&#62;&#60;br /&#62;
This is the view that I am getting: &#60;a href=&#34;http://imgur.com/13vNmEM&#34; rel=&#34;nofollow&#34;&#62;http://imgur.com/13vNmEM&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Here is my code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;% Simulating Ultrasound Beam Patterns Example
%
% This example shows how the nonlinear beam pattern from an ultrasound
% transducer can be modelled. It builds on the Defining An Ultrasound
% Transducer and Simulating Transducer Field Patterns examples.
%
% author: Bradley Treeby
% date: 27th July 2011
% last update: 25th September 2012
%
% This function is part of the k-Wave Toolbox (&#60;a href=&#34;http://www.k-wave.org&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org&#60;/a&#62;)
% Copyright (C) 2009-2014 Bradley Treeby and Ben Cox

% This file is part of k-Wave. k-Wave is free software: you can
% redistribute it and/or modify it under the terms of the GNU Lesser
% General Public License as published by the Free Software Foundation,
% either version 3 of the License, or (at your option) any later version.
%
% k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
% FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
% more details.
%
% You should have received a copy of the GNU Lesser General Public License
% along with k-Wave. If not, see &#38;lt;http://www.gnu.org/licenses/&#38;gt;. 

clear all;

% simulation settings
DATA_CAST = &#38;#39;single&#38;#39;;       % set to &#38;#39;single&#38;#39; or &#38;#39;gpuArray-single&#38;#39; to speed up computations
MASK_PLANE = &#38;#39;xy&#38;#39;;          % set to &#38;#39;xy&#38;#39; or &#38;#39;xz&#38;#39; to generate the beam pattern in different planes
USE_STATISTICS = true;      % set to true to compute the rms or peak beam patterns, set to false to compute the harmonic beam patterns

% =========================================================================
% DEFINE THE K-WAVE GRID
% =========================================================================

% set the size of the perfectly matched layer (PML)
PML_X_SIZE = 20;            % [grid points]
PML_Y_SIZE = 10;            % [grid points]
PML_Z_SIZE = 10;            % [grid points]

% set total number of grid points not including the PML
Nx = 128 - 2*PML_X_SIZE;    % [grid points]
Ny = 256 - 2*PML_Y_SIZE;     % [grid points]
Nz = 64 - 2*PML_Z_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]
dz = dx;                    % [m]

% create the k-space grid
kgrid = makeGrid(Nx, dx, Ny, dy, Nz, dz);

% =========================================================================
% DEFINE THE MEDIUM PARAMETERS
% =========================================================================

% define the properties of the propagation medium
medium.sound_speed = 1540;      % [m/s]
medium.density = 1000;          % [kg/m^3]
medium.alpha_coeff = 0.75;      % [dB/(MHz^y cm)]
medium.alpha_power = 1.5;
medium.BonA = 6;

% create the time array
t_end = 45e-6;                  % [s]
kgrid.t_array = makeTime(kgrid, medium.sound_speed, [], t_end);

% =========================================================================
% DEFINE THE INPUT SIGNAL
% =========================================================================

% define properties of the input signal
source_strength = 1e6;          % [Pa]
tone_burst_freq = 0.5e6;    	% [Hz]
tone_burst_cycles = 5;

% define a circular source element
source_radius = 15;  % [grid points]
source_shape  = makeDisc(Nx, Ny, Nx/2, Ny/2, source_radius);

% assign source element to source mask
source_z_pos = 12;  % [grid points]
source.p_mask = zeros(Nx, Ny, Nz);
source.p_mask(:, :, source_z_pos) = source_shape;

% define source input
source_freq = 2e6;  % [Hz]
num_cycles = 5;
source_signal = toneBurst(1/kgrid.dt, source_freq, num_cycles);

% create time delays to focus the transducer and assign to source
focus_position = round([0,0,0]);
source.p = focus(kgrid, source_signal, source.p_mask, focus_position, 1450);

% =========================================================================
% DEFINE SENSOR MASK
% =========================================================================

% define a sensor mask through the central plane
sensor.mask = zeros(Nx, Ny, Nz);
switch MASK_PLANE
    case &#38;#39;xy&#38;#39;
        % define mask
        sensor.mask(:, :, Nz/2) = 1;

        % store y axis properties
        Nj = Ny;
        j_vec = kgrid.y_vec;
        j_label = &#38;#39;y&#38;#39;;

    case &#38;#39;xz&#38;#39;
        % define mask
        sensor.mask(:, Ny/2, :) = 1;

        % store z axis properties
        Nj = Nz;
        j_vec = kgrid.z_vec;
        j_label = &#38;#39;z&#38;#39;;

end 

% set the record mode such that only the rms and peak values are stored
if USE_STATISTICS
    sensor.record = {&#38;#39;p_rms&#38;#39;, &#38;#39;p_max&#38;#39;};
end

% =========================================================================
% RUN THE SIMULATION
% =========================================================================

% set the input settings
input_args = {&#38;#39;DisplayMask&#38;#39;, source.p_mask, ...
    &#38;#39;PMLInside&#38;#39;, false, &#38;#39;PlotPML&#38;#39;, false, &#38;#39;PMLSize&#38;#39;, [PML_X_SIZE, PML_Y_SIZE, PML_Z_SIZE], ...
    &#38;#39;DataCast&#38;#39;, DATA_CAST, &#38;#39;DataRecast&#38;#39;, true, &#38;#39;PlotScale&#38;#39;, [-source_strength/2, source_strength/2]};

% stream the data to disk in blocks of 100 if storing the complete time
% history
if ~USE_STATISTICS
    input_args = [input_args {&#38;#39;StreamToDisk&#38;#39;, 100}];
end

% run the simulation
sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});

% =========================================================================
% COMPUTE THE BEAM PATTERN USING SIMULATION STATISTICS
% =========================================================================

if USE_STATISTICS

    % reshape the returned rms and max fields to their original position
    sensor_data.p_rms = reshape(sensor_data.p_rms, [Nx, Nj]);
    sensor_data.p_max = reshape(sensor_data.p_max, [Nx, Nj]);

    % plot the beam pattern using the pressure maximum
    figure;
    imagesc(j_vec*1e3, (kgrid.x_vec - min(kgrid.x_vec(:)))*1e3, sensor_data.p_max/1e6);
    xlabel([j_label &#38;#39;-position [mm]&#38;#39;]);
    ylabel(&#38;#39;x-position [mm]&#38;#39;);
    title(&#38;#39;Total Beam Pattern Using Maximum Of Recorded Pressure&#38;#39;);
    colormap(jet(256));
    c = colorbar;
    ylabel(c, &#38;#39;Pressure [MPa]&#38;#39;);
    axis image;

    % plot the beam pattern using the pressure rms
    figure;
    imagesc(j_vec*1e3, (kgrid.x_vec - min(kgrid.x_vec(:)))*1e3, sensor_data.p_rms/1e6);
    xlabel([j_label &#38;#39;-position [mm]&#38;#39;]);
    ylabel(&#38;#39;x-position [mm]&#38;#39;);
    title(&#38;#39;Total Beam Pattern Using RMS Of Recorded Pressure&#38;#39;);
    colormap(jet(256));
    c = colorbar;
    ylabel(c, &#38;#39;Pressure [MPa]&#38;#39;);
    axis image;

    % end the example
    return

end

% =========================================================================
% COMPUTE THE BEAM PATTERN FROM THE AMPLITUDE SPECTRUM
% =========================================================================

% reshape the sensor data to its original position so that it can be
% indexed as sensor_data(x, j, t)
sensor_data = reshape(sensor_data, [Nx, Nj, kgrid.Nt]);

% compute the amplitude spectrum
[freq, amp_spect] = spect(sensor_data, 1/kgrid.dt, &#38;#39;Dim&#38;#39;, 3);

% compute the index at which the source frequency and its harmonics occur
[f1_value, f1_index] = findClosest(freq, tone_burst_freq);
[f2_value, f2_index] = findClosest(freq, tone_burst_freq*2);

% extract the amplitude at the source frequency and store
beam_pattern_f1 = amp_spect(:, :, f1_index);

% extract the amplitude at the second harmonic and store
beam_pattern_f2 = amp_spect(:, :, f2_index);       

% extract the integral of the total amplitude spectrum
beam_pattern_total = sum(amp_spect, 3);

% plot the beam patterns
figure;
imagesc(j_vec*1e3, (kgrid.x_vec - min(kgrid.x_vec(:)))*1e3, beam_pattern_f1/1e6);
xlabel([j_label &#38;#39;-position [mm]&#38;#39;]);
ylabel(&#38;#39;x-position [mm]&#38;#39;);
title(&#38;#39;Beam Pattern At Source Fundamental&#38;#39;);
colormap(jet(256));
c = colorbar;
ylabel(c, &#38;#39;Pressure [MPa]&#38;#39;);
axis image;

figure;
imagesc(j_vec*1e3, (kgrid.x_vec - min(kgrid.x_vec(:)))*1e3, beam_pattern_f2/1e3);
xlabel([j_label &#38;#39;-position [mm]&#38;#39;]);
ylabel(&#38;#39;x-position [mm]&#38;#39;);
title(&#38;#39;Beam Pattern At Second Harmonic&#38;#39;);
colormap(jet(256));
c = colorbar;
ylabel(c, &#38;#39;Pressure [kPa]&#38;#39;);
axis image;

figure;
imagesc(j_vec*1e3, (kgrid.x_vec - min(kgrid.x_vec(:)))*1e3, beam_pattern_total/1e6);
xlabel([j_label &#38;#39;-position [mm]&#38;#39;]);
ylabel(&#38;#39;x-position [mm]&#38;#39;);
title(&#38;#39;Total Beam Pattern Using Integral Of Recorded Pressure&#38;#39;);
colormap(jet(256));
c = colorbar;
ylabel(c, &#38;#39;Pressure [MPa]&#38;#39;);
axis image;

% =========================================================================
% PLOT DIRECTIVITY PATTERN AT FOCUS
% =========================================================================

% compute the directivity at each of the harmonics
directivity_f1 = squeeze(beam_pattern_f1(round(transducer.focus_distance/dx), :));
directivity_f2 = squeeze(beam_pattern_f2(round(transducer.focus_distance/dx), :));

% normalise
directivity_f1 = directivity_f1./max(directivity_f1(:));
directivity_f2 = directivity_f2./max(directivity_f2(:));

% compute relative angles from transducer
if strcmp(MASK_PLANE, &#38;#39;xy&#38;#39;)
    horz_axis = ((1:Ny) - Ny/2)*dy;
else
    horz_axis = ((1:Nz) - Nz/2)*dz;
end
angles = 180*atan2(horz_axis, transducer.focus_distance)/pi;

% plot the directivity
figure;
plot(angles, directivity_f1, &#38;#39;k-&#38;#39;, angles, directivity_f2, &#38;#39;k--&#38;#39;);
axis tight;
set(gca, &#38;#39;FontSize&#38;#39;, 12);
xlabel(&#38;#39;Angle [deg]&#38;#39;);
ylabel(&#38;#39;Normalised Amplitude&#38;#39;);
legend(&#38;#39;Fundamental&#38;#39;, &#38;#39;Second Harmonic&#38;#39;, &#38;#39;Location&#38;#39;, &#38;#39;NorthWest&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Sorry if this doesn't make any sense! Thank you.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
