legnum

Add legend using vector of numbers.
1.4K Downloads
Updated 14 Apr 2016

View License

LEGNUM Legend current figure using array of numbers. LEGNUM(X) adds a legend to current figure using string representations of the numbers in X. If X is a two- or multi-dimensional array, it will be flattened and all elements will be included.

LEGNUM(X, P) is the same but uses precision P, where P is an integer.

LEGNUM(X, P, S) same as above but includes a prefix string to each legend label.

Examples
>legnum(logspace(-5,-4,7), 6);

Adds a legend with logarithmically-spaced number labels, with 6 significant digit precision

> legnum(logspace(-5,-4,7), 6, 'x = ');

Same but labels are of the form 'x = 1e-5', etc.

See also NUM2CELLSTR

NUM2CELLSTR convert array of floating-point numbers to cell array of strings.

NUM2CELLSTR(X) converts array X to cell array of strings. If X is a two- or multi-dimensional array, it will be flattened (all elements will still be included).

NUM2CELLSTR(X, P) is the same but uses precision P, where P is an integer.

NUM2CELLSTR(X, P, S) same as above but includes a prefix string to each cell. This clumsy routine would be unnecessary if MATLAB provided something like python's string.strip() function.

See also SPRINTF, CELLSTR

Alex Barnett 12/5/02

Cite As

Alex Barnett (2026). legnum (https://www.mathworks.com/matlabcentral/fileexchange/2821-legnum), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R12.1
Compatible with any release
Platform Compatibility
Windows macOS Linux
Version Published Release Notes
1.0.0.0

give it a license
bug in argument handling corrected