MATLAB Answers


single precision simulation of internal calculations

Asked by Marc Adams on 28 May 2019
Latest activity Commented on by Honglei Chen
on 3 Jun 2019
I would like to experiment with beamforming. The hardware which may host the algorithm is only able to support single precision calculations. Is there a way to set Matlab to perform all calculations (even internal) to single precision? I am writing this iteration of the beamformer to avoid the use of toolboxes and their functions. Since this attempt is a first order estimate, I am limting the calculations to elementary mathemtical functions (exponentials, sines etc.).


Thanks for pointing out that documentation page. I think it is in need of updating to reflect the increase in capability of Phased Array System Toolbox in recent releases. I've brought it to the attention of the documentation staff.
Could you point me to something in the documentation that will allow me to set the precision of the internal calculations for the phased array toolbox. I haven't found it yet.
There is nothing for you to specifically set. It depends on the input you pass in. In general, we use the data type of the data input to determine what precision of the interal calculation. For example, if your data input of the PhaseShiftBeamformer is single, then the computation will be carried out in single.

Sign in to comment.

1 Answer

Answer by James Tursa
on 28 May 2019
Edited by James Tursa
on 28 May 2019
 Accepted Answer

" Is there a way to set Matlab to perform all calculations (even internal) to single precision? "
Not the way you are probably wanting. E.g., the literal constant 2 will always be interpreted as a double precision value ... there is no setting that I am aware of that will change that. This forces you to explicitly use single(2) in your code to force a single precision value. Also, there may be library code that MATLAB relies on that uses double (or higher) precision in the background (e.g., double precision accumulators used for single precision inputs, etc.). Strict sIngle precision emulation really isn't something MATLAB is set up to do well.


Sign in to comment.