No BSD License  

Highlights from
legnum

5.0

5.0 | 3 ratings Rate this file 0 Downloads (last 30 days) File Size: 1.33 KB File ID: #2821

legnum

by Alex Barnett

 

05 Dec 2002 (Updated 10 Dec 2002)

Add legend using vector of numbers.

| Watch this File

File Information
Description

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

MATLAB release MATLAB 6.1 (R12.1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
24 Mar 2003 Richard Sims

Just what I needed! Easy to use and the precision option is great.

12 Jul 2004 cosmic insanity

I've been wanting to solve this problem for ages, now lazyness has paid off. Works great, thanks!

30 Jun 2009 Rohit  
Please login to add a comment or rating.
Updates
10 Dec 2002

bug in argument handling corrected

Tag Activity for this File
Tag Applied By Date/Time
annotation Alex Barnett 22 Oct 2008 06:54:43
customization Alex Barnett 22 Oct 2008 06:54:43
legend Alex Barnett 22 Oct 2008 06:54:43
string Alex Barnett 22 Oct 2008 06:54:43
array Alex Barnett 22 Oct 2008 06:54:43
graphics Alex Barnett 22 Oct 2008 06:54:43

Contact us at files@mathworks.com