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 (2024). legnum (https://www.mathworks.com/matlabcentral/fileexchange/2821-legnum), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | give it a license
|