File Exchange

image thumbnail

High intensity focused ultrasound simulator

version (180 KB) by Josh Soneson
Simulates high intensity focused ultrasound beams and heating effects in layered media


Updated 29 Mar 2011

View License

Contains two modules. The first solves the KZK equation for the pressure distribution of an axisymmetric focused ultrasound transducer, produces salient plots, and dumps the computed data to the Matlab workspace. The second module uses the pressure distribution to compute heating and thermal dose according to a user-defined treatment protocol. Again plots are produced and data is available for postprocessing.

Cite As

Josh Soneson (2021). High intensity focused ultrasound simulator (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (17)

Lama Awawdeh

when i run the code, t shows an error message which says that ((Undefined function or variable 'axisymmetricKZK'.)) Any help?

Josh Soneson

This version is now obsolete. I've uploaded an improved version of this package to GitHub. A brief description and download link are here:

George Menikou

after running the BHT i get this error (default KZK and BHT parameters were used) .....any guesses????

Error using contour (line 48)
Vector Y must be strictly increasing or strictly decreasing with no repeated values.

Error in BHT_plots (line 15)
[C,H]=contour(z,r2,Dmat2,[.1 .1]);

Error in axisymmetricBHT (line 59)

f o

pouya nam

I face to error from BHT can someone help me ?


I met a question as I run the program of High intensity focused ultrasound simulator
Warning--f/1.18 exceeds the conditions
under which KZK is derived (> f/1.37).
Is there anybody who can help me for it? Thanks.

Tom Williamson

Hi Alessandra,

I think you're talking about the issue with the plotting of the final temperature maps, this is the error I was getting: "Error using contour (line 48) Vector Y must be strictly increasing or strictly decreasing with no repeated values."

You need to change the following three lines in BHT_Plots.m:
(13) r2 = [-flipud(r(1:length(r)-1));r];
(14) Dmat2 = [flipud(Dmat(1:length(r)-1,:));Dmat];
(41) Tmax_mat2 = [flipud(Tmax_mat(1:length(r)-1,:));Tmax_mat];

to the following:

(13) r2 = [-flipud(r(2:length(r)));r];
(14) Dmat2 = [flipud(Dmat(2:length(r),:));Dmat];
(41) Tmax_mat2 = [flipud(Tmax_mat(2:length(r),:));Tmax_mat];

Newer versions of Matlab throw an error that didn't exist when this was developed.
Hope this helps anyone who happens to come across this.


Is anyone else having errors with the heating code example?


Really excellent code for HIFU simulation. It is very user-friendly and the outputs are very clean.

hu dong

THe BHT_parameters.m program has some wrong.
t = [0:dt:T]; % time nodes
r = r(1:r_skip:round(J/2));
z = z(1:z_skip:M);
H = H(1:r_skip:round(J/2),1:z_skip:M);
[J,M] = size(H);
fprintf('\n\tdt = %2.2f sec\tN = %d\n',dt,N)
fprintf('\tdr = %2.2f mm\tJ = %d\n',10*r(2),J)
fprintf('\tdz = %2.2f mm\tM = %d\n\n',10*z(2),M)


Excellent code, but I didnt manage to change the parameters of sonication. I want to simulate a CW sequence of 60s and 48s of cooling. I set t_i=60 and t_c=48 and set number of pulses to 0 but the code persists on default values.


Excellent HIFU simulation codes!THANKS!

Martin Skjelvareid

Well documented and with a large set of relevant output parameters.

Martin Skjelvareid


Nice code, fast (axisymmetric calculation) and user-friendly.
It would be good to be able to specify more than 2 materials.


Should provide constants (alpha, beta, eta) for some other commonly used materials and media (like air) and/or cite sources on where to get them. Thanks


The software looks good although some basic sketches of the geometries, transducer positioning, materials, axes, naming conventions, etc. should be included in the instructions in order to understand basic examples and develop more advanced ones.

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!