Hello,
I am having some difficulty understanding how kWave handles different time varying pressures for different sources. Assuming I have 8 sources distributed circularly in the grid, I need to define 8 different pressure signals, one for each source. This I have done by making source.p a (number_of_sources)x(length(kgrid.t_array)) array.
Given that sources are defined just by 1 s on the grid array (there is no ordering), I am having some problem understanding how can I match the rows of the source.p array to the actual sources on the grid. To put it more simply, how does the software know which source signal corresponds to each source?
In the documentation it is mentioned that source.p can be " a matrix of time series following the source elements using MATLAB's standard columnwise linear matrix index ordering" which I am finding hard to decipher.
Any help would be greatly appreciated as I am stuck on this for a couple of days.
best regards,
georgios
kWave
A MATLAB toolbox for the timedomain
simulation of acoustic wave fields
How to define pressure waves for multiple sources
(3 posts) (2 voices)
Posted 12 years ago #

Hi Georgios,
Thanks for your question. Matrices in MATLAB are actually stored in memory as a onedimensional sequence of numbers. The numbers are stored column by column moving top to bottom and left to right. Instead of using the row and column index to access a particular position in a matrix, we can also use its position in this sequence (this is called the linear index). From the MATLAB documentation:
"Matrix A
A = [2 6 9; 4 2 8; 3 5 1] A = 2 6 9 4 2 8 3 5 1
is actually stored in memory as the sequence
2, 4, 3, 6, 2, 5, 9, 8, 1
The element at row 3, column 2 of matrix A (value = 5) can also be identified as element 6 in the actual storage sequence. To access this element, you have a choice of using the standard A(3,2) syntax, or you can use A(6), which is referred to as linear indexing."
This ordering is used to order the source points (and the sensor points) in kWave. For example, if your binary mask for
source.p_mask
was equal to a circle:source.p_mask = 0 1 0 1 0 1 1 0 1 0 1 0
The actual ordering of the source points would follow:
source.p_mask = 0 3 0 1 0 5 2 0 6 0 4 0
This is the ordering used in assigning the source terms to
source.p
etc.I hope that helps  let me know if you still have any questions. We will work on making the documentation clearer for the next release.
Brad.
Posted 12 years ago # 
Hi Brad,
many thanks for your response and also for making this work public,
it s pretty clear to me now,
best,
georgiosPosted 12 years ago #
Reply
You must log in to post.