<?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: &#34;Arrays have incompatible sizes for this operation.&#34;</title>
		<link>http://www.k-wave.org/forum/topic/arrays-have-incompatible-sizes-for-this-operation</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 22:34:15 +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/arrays-have-incompatible-sizes-for-this-operation" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "&#34;Arrays have incompatible sizes for this operation.&#34;"</title>
			<link>http://www.k-wave.org/forum/topic/arrays-have-incompatible-sizes-for-this-operation#post-8930</link>
			<pubDate>Sun, 08 Oct 2023 13:09:26 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">8930@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;One cause of this problem is collision between the k-Wave smooth function, and the smooth function in the curve fitting toolbox. If you have this installed, try removing it from the MATLAB path, or alternatively, rename the k-Wave smooth function (eg to ksmooth).
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Sienna on "&#34;Arrays have incompatible sizes for this operation.&#34;"</title>
			<link>http://www.k-wave.org/forum/topic/arrays-have-incompatible-sizes-for-this-operation#post-8845</link>
			<pubDate>Thu, 22 Jun 2023 10:43:33 +0000</pubDate>
			<dc:creator>Sienna</dc:creator>
			<guid isPermaLink="false">8845@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I've got the same problem. Working in version 1.4.0.&#60;/p&#62;
&#60;p&#62;Full error:&#60;br /&#62;
Arrays have incompatible sizes for this operation.&#60;/p&#62;
&#60;p&#62;Error in kspaceFirstOrder2D (line 920)&#60;br /&#62;
        ux_sgx = dt .* rho0_sgx_inv .* real(ifft2( bsxfun(@times, ddx_k_shift_pos, kappa .* fft2(p)) )) / 2;&#60;/p&#62;
&#60;p&#62;Error in trial1 (line 30)&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor);&#60;/p&#62;
&#60;p&#62;I had a look and I think the problem is within the multiplication of kappa (which is 128x128 double) and fft2(p) (which is 16384x1). But I do not know how to solve it.&#60;/p&#62;
&#60;p&#62;Any help is appreciated! Thankyou.&#60;/p&#62;
&#60;p&#62;---&#60;br /&#62;
Update:&#60;/p&#62;
&#60;p&#62;I solved it for now, for others:&#60;br /&#62;
Smooth changed the source.p0 from 128x128 to 16384x1, so you can circumvent by running the simulation by: sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, Smooth=[false,false,false]);
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "&#34;Arrays have incompatible sizes for this operation.&#34;"</title>
			<link>http://www.k-wave.org/forum/topic/arrays-have-incompatible-sizes-for-this-operation#post-8760</link>
			<pubDate>Thu, 18 May 2023 06:16:58 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">8760@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;The first one is old syntax, but your second example I'm able to run without any errors in k-Wave 1.4. Could you post the full error message? Have you tried selecting &#34;Run the file in MATLAB&#34; for any of the examples in the MATLAB help browser?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>sjm212 on "&#34;Arrays have incompatible sizes for this operation.&#34;"</title>
			<link>http://www.k-wave.org/forum/topic/arrays-have-incompatible-sizes-for-this-operation#post-8751</link>
			<pubDate>Sun, 14 May 2023 19:00:22 +0000</pubDate>
			<dc:creator>sjm212</dc:creator>
			<guid isPermaLink="false">8751@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi All,&#60;br /&#62;
I am just starting out with the k-wave toolbox and have begun working through the examples to get a grasp on the functionality. I immediately ran into issues when running the kspaceFirstOrder2D function getting the &#34;Arrays have incompatible sizes for this operation.&#34; error multiple times from multiple examples. &#60;/p&#62;
&#60;p&#62;Listed below are the scripts I have run to get the errors.&#60;/p&#62;
&#60;p&#62;%% ----- %%&#60;/p&#62;
&#60;p&#62;From the User Manual:&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
Nx = 128; % number of grid points in the x (row) direction&#60;br /&#62;
Ny = 256; % number of grid points in the y (column) direction&#60;br /&#62;
dx = 50e-6; % grid point spacing in the x direction [m]&#60;br /&#62;
dy = 50e-6; % grid point spacing in the y direction [m]&#60;br /&#62;
kgrid = makeGrid(Nx, dx, Ny, dy);&#60;br /&#62;
% define the medium properties&#60;br /&#62;
medium.sound_speed = 1500*ones(Nx, Ny); % [m/s]&#60;br /&#62;
medium.sound_speed(1:50, :) = 1800; % [m/s]&#60;br /&#62;
medium.density = 1040; % [kg/m^3]&#60;br /&#62;
% define an initial pressure using makeDisc&#60;br /&#62;
disc_x_pos = 75; % [grid points]&#60;br /&#62;
disc_y_pos = 120; % [grid points]&#60;br /&#62;
disc_radius = 8; % [grid points]&#60;br /&#62;
disc_mag = 3; % [Pa]&#60;br /&#62;
source.p0 = disc_mag*makeDisc(Nx, Ny, disc_x_pos, disc_y_pos, disc_radius);&#60;br /&#62;
% define a Cartesian sensor mask of a centered circle with 50 sensor elements&#60;br /&#62;
sensor_radius = 2.5e-3; % [m]&#60;br /&#62;
num_sensor_points = 50;&#60;br /&#62;
sensor.mask = makeCartCircle(sensor_radius, num_sensor_points);&#60;br /&#62;
% run the simulation&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor);&#60;/p&#62;
&#60;p&#62;From the MATLAB Examples Site:&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
Nx = 128;           % number of grid points in the x (row) direction&#60;br /&#62;
Ny = 128;           % number of grid points in the y (column) 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;
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 initial pressure distribution using makeDisc&#60;br /&#62;
disc_magnitude = 5; % [Pa]&#60;br /&#62;
disc_x_pos = 50;    % [grid points]&#60;br /&#62;
disc_y_pos = 50;    % [grid points]&#60;br /&#62;
disc_radius = 8;    % [grid points]&#60;br /&#62;
disc_1 = disc_magnitude * makeDisc(Nx, Ny, disc_x_pos, disc_y_pos, disc_radius);&#60;/p&#62;
&#60;p&#62;disc_magnitude = 3; % [Pa]&#60;br /&#62;
disc_x_pos = 80;    % [grid points]&#60;br /&#62;
disc_y_pos = 60;    % [grid points]&#60;br /&#62;
disc_radius = 5;    % [grid points]&#60;br /&#62;
disc_2 = disc_magnitude * makeDisc(Nx, Ny, disc_x_pos, disc_y_pos, disc_radius);&#60;/p&#62;
&#60;p&#62;source.p0 = disc_1 + disc_2;&#60;/p&#62;
&#60;p&#62;% define a centered circular sensor&#60;br /&#62;
sensor_radius = 4e-3;   % [m]&#60;br /&#62;
num_sensor_points = 50;&#60;br /&#62;
sensor.mask = makeCartCircle(sensor_radius, num_sensor_points);&#60;/p&#62;
&#60;p&#62;% run the simulation&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor);&#60;/p&#62;
&#60;p&#62;%% ----- %%&#60;/p&#62;
&#60;p&#62;What is interesting is that running Program 1 from page 3 of Treeby et al. (&#60;a href=&#34;http://bug.medphys.ucl.ac.uk/papers/2014-Treeby-IEEEIUS.pdf&#34; rel=&#34;nofollow&#34;&#62;http://bug.medphys.ucl.ac.uk/papers/2014-Treeby-IEEEIUS.pdf&#60;/a&#62;) leads to no errors and a properly run simulation. &#60;/p&#62;
&#60;p&#62;Any help would be greatly appreciated!&#60;/p&#62;
&#60;p&#62;Sincere Thanks,&#60;/p&#62;
&#60;p&#62;SJM212
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
