View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
MetricPrefixStr - Print SI Prefix Formatted Numbers

2.0 | 1 rating Rate this file 3 Downloads (last 30 days) File Size: 1.71 KB File ID: #41000 Version: 1.0

MetricPrefixStr - Print SI Prefix Formatted Numbers


Damon Bradley (view profile)


Prints a SI prefix formatted string corresponding to a numeric vector.

| Watch this File

File Information

Author: Damon Bradley
Purpose: Print out formatted string using SI prefixes to clean up plots
for quantities in the thousands, millions, billions and trillions. This is useful for
publication-quality plots.

Version 1.0, March 28, 2013

INPUTS: xtickvec - Any vector of numbers
OUTPUTS: str - An array of strings with properly formatted numbers


labels = MetricPrefixStr([1 10 100 33.64 1000 2000 40000 340000 7000000 1e14])

labels =

'1' '10' '100' '33.64' '1k' '2k' '40k' '340k' '7M' '100T'

class labels
ans =



This file inspired Number To Scientific Prefix and Scientific Prefix To Number.

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
18 Jul 2014 Stephen Cobeldick

Disclaimer: In the end I could not find any FEX submission that gave the correct outputs for the wide range of test-cases that I tried, so I ended up writing my own function. You can find it here:

Comment only
18 Jul 2014 Stephen Cobeldick

While it claims to be suitable for "publication-quality plots", the lack of the space character between the coefficient and the prefix means that this submission actually does not follow the SI standard. It also entirely lacks the prefixes y, z, a, f, p, n, u, m, P, E, Z, and Y. And while it gives some examples, the example on line 20 "class labels" shows a basic misunderstanding between Command Syntax and Function Syntax in MATLAB:

The code could be much simpler: the use of (slow) "repmat" is not required (just use the format string itself, eg: '%d k', etc), and that whitespace removal code is bizarre: why not simply "strtrim(xtick)" ?. Precision control, returning my NaN values, an H1 line and input checking would be nice too!

Contact us