<?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; Topic: 2D linear array transducer with karray.addRectElement</title>
		<link>http://www.k-wave.org/forum/topic/2d-linear-array-transducer-with-karrayaddrectelement</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 21:24:05 +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/topic/2d-linear-array-transducer-with-karrayaddrectelement" rel="self" type="application/rss+xml" />

		<item>
			<title>mhopeng on "2D linear array transducer with karray.addRectElement"</title>
			<link>http://www.k-wave.org/forum/topic/2d-linear-array-transducer-with-karrayaddrectelement#post-9227</link>
			<pubDate>Sat, 02 Aug 2025 01:08:13 +0000</pubDate>
			<dc:creator>mhopeng</dc:creator>
			<guid isPermaLink="false">9227@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;You need to define the elements of the Array using one of the methods for adding elements, such as &#60;code&#62;addRectElement()&#60;/code&#62;. I don't see that in the code you have posted here.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>masud407 on "2D linear array transducer with karray.addRectElement"</title>
			<link>http://www.k-wave.org/forum/topic/2d-linear-array-transducer-with-karrayaddrectelement#post-9210</link>
			<pubDate>Thu, 24 Apr 2025 17:25:58 +0000</pubDate>
			<dc:creator>masud407</dc:creator>
			<guid isPermaLink="false">9210@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I am trying to simulate a linear array which I can do for 3D case using the following example:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.k-wave.org/documentation/example_at_linear_array_transducer.php&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org/documentation/example_at_linear_array_transducer.php&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;However, I was trying to modify it for 2D case as following:&#60;/p&#62;
&#60;p&#62;clearvars;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE LITERALS&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% select which k-Wave code to run&#60;br /&#62;
%   1: MATLAB CPU code&#60;br /&#62;
%   2: MATLAB GPU code&#60;br /&#62;
%   3: C++ code&#60;br /&#62;
%   4: CUDA code&#60;br /&#62;
model           = 2;&#60;/p&#62;
&#60;p&#62;% medium parameters&#60;br /&#62;
c0              =1540;     % sound speed [m/s]&#60;br /&#62;
cs1 = 5;        % shear wave speed&#60;br /&#62;
alpha0_p1 = 0.002;        % absorption coefficient for water  % [dB/(MHz^2 cm)]&#60;br /&#62;
alpha0_s1 = 0.002;        % absorption coefficient for water (shear)&#60;br /&#62;
rho0            = 1000;     % density [kg/m^3]&#60;/p&#62;
&#60;p&#62;%define acrylic layer_tissue&#60;br /&#62;
cp2 = 2750;   % Longitudinal wave speed&#60;br /&#62;
cs2 = 1150;     % shear wave speed&#60;br /&#62;
rho2 = 1180;  %density&#60;br /&#62;
%alpha0_p2 = 0.5;        % absorption coefficient&#60;br /&#62;
%alpha0_s2 = 0.5;        % absorption coefficient&#60;br /&#62;
alpha0_p2 = 1.58;        % absorption coefficient  % [dB/(MHz^2 cm)]&#60;br /&#62;
alpha0_s2 =  0.016;        % absorption coefficient&#60;/p&#62;
&#60;p&#62;% source parameters&#60;br /&#62;
source_f0       =1e6;      % source frequency [Hz]&#60;br /&#62;
source_amp      = 1e6;      % source pressure [Pa]&#60;br /&#62;
source_cycles   = 12;        % number of toneburst cycles %12&#60;br /&#62;
source_focus    = 35e-3;    % focal length [m]&#60;br /&#62;
element_num     = 90;       % number of elements&#60;br /&#62;
element_width   = 0.25e-3;     % width [m]&#60;br /&#62;
element_length  = 7e-3;    % elevation height [m]&#60;br /&#62;
element_pitch   = 0.3e-3;     % pitch [m]0.03mm&#60;/p&#62;
&#60;p&#62;% transducer position&#60;br /&#62;
translation     = [0, 0];&#60;br /&#62;
rotation        = [0, 0];&#60;/p&#62;
&#60;p&#62;% grid parameters&#60;br /&#62;
grid_size_x     = 40e-3;    % [m]&#60;br /&#62;
grid_size_y     = 20e-3;    % [m]&#60;br /&#62;
% grid_size_z     = 40e-3;    % [m]&#60;/p&#62;
&#60;p&#62;% computational parameters&#60;br /&#62;
ppw             = 4;        % number of points per wavelength&#60;br /&#62;
t_end           = 35e-6;    % total compute time [s]&#60;br /&#62;
cfl             = 0.1;      % CFL number&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% RUN SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% --------------------&#60;br /&#62;
% GRID&#60;br /&#62;
% --------------------&#60;/p&#62;
&#60;p&#62;% calculate the grid spacing based on the PPW and F0&#60;br /&#62;
%  dx = 2*c0 / (ppw * source_f0);   % [m]&#60;br /&#62;
 dx=  1.9250e-04;&#60;br /&#62;
% compute the size of the grid&#60;br /&#62;
Nx = roundEven(grid_size_x / dx);&#60;br /&#62;
Ny = roundEven(grid_size_y / dx);&#60;br /&#62;
% Nz = roundEven(grid_size_z / dx);&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
% kgrid = kWaveGrid(Nx, dx, Ny, dx, Nz, dx);&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dx);&#60;br /&#62;
% create the time array&#60;br /&#62;
kgrid.makeTime(c0, cfl, t_end);&#60;/p&#62;
&#60;p&#62;% --------------------&#60;br /&#62;
% SOURCE&#60;br /&#62;
% --------------------&#60;/p&#62;
&#60;p&#62;% set indices for each element&#60;br /&#62;
if rem(element_num, 2)&#60;br /&#62;
    ids = (1:element_num) - ceil(element_num/2);&#60;br /&#62;
else&#60;br /&#62;
    ids = (1:element_num) - (element_num + 1)/2;&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% set time delays for each element to focus at source_focus&#60;br /&#62;
time_delays = -(sqrt((ids .* element_pitch).^2 + source_focus.^2) - source_focus) ./ c0;&#60;br /&#62;
time_delays = time_delays - min(time_delays);&#60;br /&#62;
time_delays = 1*time_delays;&#60;br /&#62;
% create time varying source signals (one for each physical element)&#60;br /&#62;
source_sig = source_amp .* toneBurst(1/kgrid.dt, source_f0, source_cycles, 'SignalOffset', round(time_delays / kgrid.dt));&#60;/p&#62;
&#60;p&#62;% create empty kWaveArray&#60;br /&#62;
karray = kWaveArray('BLITolerance', 0.05, 'UpsamplingRate', 10);&#60;/p&#62;
&#60;p&#62;Unfortunately, I am getting the following error: &#60;/p&#62;
&#60;p&#62;Expected input number 4, theta, to be an array with number of elements equal to 1.&#60;/p&#62;
&#60;p&#62;Error in kWaveArray/addRectElement (line 715)&#60;br /&#62;
            validateattributes(theta, {'numeric'}, {'finite', 'real', 'numel', theta_length}, 'addRectElement', 'theta', 4);&#60;/p&#62;
&#60;p&#62;Any suggestion on resolving it is highly appreciated.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
