# Rounding Off Number(s) to Specified Significant Figures

Version 1.0.0.0 (1.3 KB) by
Round off number(s) to specified significant figures, using two simple/powerful MATLAB functions.
Updated 28 Apr 2009

spa_sf Rounding Off Number(s) to Certain Significant Figures

N = spa_sf(X,SF) is the rounded off number(s) of X with the specified significant figures SF. X could be a scalar or a vector; however, SF must be a scalar.

Example 1)
X = 3.14159265359;
SF = 3;
N = spa_sf(X,SF)

> N = 3.1400

Example 2)
X = 3.14159265359; X=[X,X*2;X*3,X*4];
SF = 3;
N = spa_sf(X,SF)

> N =
3.1400 6.2800
9.4200 12.6000

* I hope it would be of any help.

### Cite As

Yuzo Toya (2024). Rounding Off Number(s) to Specified Significant Figures (https://www.mathworks.com/matlabcentral/fileexchange/23949-rounding-off-number-s-to-specified-significant-figures), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R2009a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Categories
Find more on Data Type Conversion in Help Center and MATLAB Answers