<?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: how to define source.p as a matrix</title>
		<link>http://www.k-wave.org/forum/topic/how-to-define-sourcep-as-a-matrix</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 01:00:08 +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/how-to-define-sourcep-as-a-matrix" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "how to define source.p as a matrix"</title>
			<link>http://www.k-wave.org/forum/topic/how-to-define-sourcep-as-a-matrix#post-7939</link>
			<pubDate>Thu, 26 Nov 2020 11:25:33 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7939@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Do you mean how can you remap results from an axisymmetric simulation to 3D? You could use something like &#60;code&#62;revolve2D&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;Brad
&#60;/p&#62;</description>
		</item>
		<item>
			<title>HustYjq on "how to define source.p as a matrix"</title>
			<link>http://www.k-wave.org/forum/topic/how-to-define-sourcep-as-a-matrix#post-7914</link>
			<pubDate>Tue, 03 Nov 2020 08:42:13 +0000</pubDate>
			<dc:creator>HustYjq</dc:creator>
			<guid isPermaLink="false">7914@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Bradley Treeby，&#60;br /&#62;
I want to perform a axisymmetric simulations in 3D.I have a two-dimensional matrices, and i want to rotate around an axis like  the example &#34;Simulations In An Axisymmetric Coordinate System Example&#34; .But I want to get a three-dimensional body instead of a two-dimensional plane.Every gp in  the body has value.Can i do this in K-wave?&#60;br /&#62;
Thank you!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "how to define source.p as a matrix"</title>
			<link>http://www.k-wave.org/forum/topic/how-to-define-sourcep-as-a-matrix#post-7907</link>
			<pubDate>Sun, 01 Nov 2020 22:59:14 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7907@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi HustYjq,&#60;/p&#62;
&#60;p&#62;What do you mean by wrong waveform? If you can post a small working example and let me know exactly what the problem is, I'll take a look.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>HustYjq on "how to define source.p as a matrix"</title>
			<link>http://www.k-wave.org/forum/topic/how-to-define-sourcep-as-a-matrix#post-7884</link>
			<pubDate>Mon, 19 Oct 2020 15:19:50 +0000</pubDate>
			<dc:creator>HustYjq</dc:creator>
			<guid isPermaLink="false">7884@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I have an  matrix  40 *100 of initial pressure .In some locations the pressure is not 0.And I define the source.mask as source.p_mask(12:27,1:45)=1;But I have wrong Waveform.Can anyone tell me how to solve these problem?&#60;/p&#62;
&#60;p&#62;Nx = 40;           % number of grid points in the x (row) direction&#60;br /&#62;
Ny = 100;           % 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;br /&#62;
p1 = resize(p0, [Nx, Ny]);&#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;br /&#62;
     kgrid.makeTime(medium.sound_speed);&#60;/p&#62;
&#60;p&#62;source.p_mask = zeros(Nx, Ny);&#60;br /&#62;
source.p_mask(12:27,1:45)=1;&#60;br /&#62;
j=1;&#60;br /&#62;
     for k = 1:45;&#60;br /&#62;
for i = 12:27;   &#60;/p&#62;
&#60;p&#62;        source.p(j,:)=  p1(i,k) *(heaviside(kgrid.t_array);&#60;br /&#62;
      j=j+1;&#60;/p&#62;
&#60;p&#62;    end&#60;br /&#62;
end
&#60;/p&#62;</description>
		</item>
		<item>
			<title>HustYjq on "how to define source.p as a matrix"</title>
			<link>http://www.k-wave.org/forum/topic/how-to-define-sourcep-as-a-matrix#post-7883</link>
			<pubDate>Mon, 19 Oct 2020 15:19:48 +0000</pubDate>
			<dc:creator>HustYjq</dc:creator>
			<guid isPermaLink="false">7883@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I have an  matrix  40 *100 of initial pressure .In some locations the pressure is not 0.And I define the source.mask as source.p_mask(12:27,1:45)=1;But I have wrong Waveform.Can anyone tell me how to solve these problem?&#60;/p&#62;
&#60;p&#62;Nx = 40;           % number of grid points in the x (row) direction&#60;br /&#62;
Ny = 100;           % 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;br /&#62;
p1 = resize(p0, [Nx, Ny]);&#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;br /&#62;
     kgrid.makeTime(medium.sound_speed);&#60;/p&#62;
&#60;p&#62;source.p_mask = zeros(Nx, Ny);&#60;br /&#62;
source.p_mask(12:27,1:45)=1;&#60;br /&#62;
j=1;&#60;br /&#62;
     for k = 1:45;&#60;br /&#62;
for i = 12:27;   &#60;/p&#62;
&#60;p&#62;        source.p(j,:)=  p1(i,k) *(heaviside(kgrid.t_array);&#60;br /&#62;
      j=j+1;&#60;/p&#62;
&#60;p&#62;    end&#60;br /&#62;
end
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "how to define source.p as a matrix"</title>
			<link>http://www.k-wave.org/forum/topic/how-to-define-sourcep-as-a-matrix#post-7860</link>
			<pubDate>Wed, 30 Sep 2020 09:21:57 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7860@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi HustYjq,&#60;/p&#62;
&#60;p&#62;I'd suggest working through the time varying source examples in the toolbox (you can access these using the MATLAB help browser), and the k-Wave user manual. These should tell you everything you need. Let me know if you get stuck on something specific after taking a look at these.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>HustYjq on "how to define source.p as a matrix"</title>
			<link>http://www.k-wave.org/forum/topic/how-to-define-sourcep-as-a-matrix#post-7859</link>
			<pubDate>Wed, 30 Sep 2020 09:17:01 +0000</pubDate>
			<dc:creator>HustYjq</dc:creator>
			<guid isPermaLink="false">7859@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;well,i modified my code ,but it still has problem:Input signal must be a vector.&#60;br /&#62;
p0_magnitude = 1;&#60;br /&#62;
p0 = p0_magnitude * loadImage('150mev.png');&#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;br /&#62;
% create the time array&#60;/p&#62;
&#60;p&#62;% resize the image to match the size of the computational grid and assign&#60;br /&#62;
% to the source input structure&#60;br /&#62;
p1 = resize(p0, [Nx, Ny]);&#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;source.p_mask = ones(Nx, Ny);&#60;br /&#62;
kgrid.makeTime(medium.sound_speed);&#60;br /&#62;
% define a time varying sinusoidal source&#60;br /&#62;
source_freq = 0.25e6;   % [Hz]&#60;br /&#62;
j=1;&#60;br /&#62;
    for i = 1:128       %&#60;br /&#62;
    for k = 1:128&#60;/p&#62;
&#60;p&#62;        source.p(j,:)=  p1(i,k) * sin(2 * pi * source_freq * kgrid.t_array);&#60;br /&#62;
      j=j+1;&#60;/p&#62;
&#60;p&#62;    end&#60;br /&#62;
end                 % [Pa]&#60;br /&#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;</description>
		</item>
		<item>
			<title>HustYjq on "how to define source.p as a matrix"</title>
			<link>http://www.k-wave.org/forum/topic/how-to-define-sourcep-as-a-matrix#post-7858</link>
			<pubDate>Wed, 30 Sep 2020 03:23:30 +0000</pubDate>
			<dc:creator>HustYjq</dc:creator>
			<guid isPermaLink="false">7858@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi，&#60;br /&#62;
Can anyone tell me how to define  source.p as a matrix? I load the image and get the source.p0 as a matrix.But i don't know how to define  source.p as a martix with the same size as source.p0.&#60;/p&#62;
&#60;p&#62;p0_magnitude = 1;&#60;br /&#62;
p0 = p0_magnitude * loadImage('150mev.png');&#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;% resize the image to match the size of the computational grid and assign&#60;br /&#62;
% to the source input structure&#60;br /&#62;
source.p0 = resize(p0, [Nx, Ny]);&#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;% define a time varying sinusoidal source&#60;br /&#62;
source_freq = 0.25e6;   % [Hz]&#60;br /&#62;
       for i = 1:128       %&#60;br /&#62;
    for k = 1:128&#60;br /&#62;
        source.mag = source.p0(i,k)     %&#60;br /&#62;
source.p = source.mag * sin(2 * pi * source_freq * kgrid.t_array);&#60;br /&#62;
    end&#60;br /&#62;
end                 % [Pa]&#60;br /&#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;</description>
		</item>

	</channel>
</rss>
