STEMLEAFPLOT plots stem-leaf plots of the input V to the command window.
Leaf precision may be defined by the user. Note that inputs will be
rounded to the nearest leaf unit (http://en.wikipedia.org/wiki/Stemplot).
INPUT
V : Array of numerical inputs (NaN values are ignored)
OPTION
P : Leaf precision (defined as integer power of 10)
Stem precision (by default) is 10^(P+1).
P is automatically rounded at the beginning of the function.
Leaf and stem units are printed at the bottom of the graph.
Examples: P = -3 rounds V to the nearest 10^-3 = 0.001
P = 3 rounds V to the nearest 10^3 = 1000
[DEFAULT: P = 0]
OUTPUT
Command window output
EXAMPLES
% Stem-leaf plot of V with unit precision
V = 10.*randn(1,50);
stemleafplot(V)
% Stem-leaf plot of V with precision of 0.1
V = randn(1,50);
stemleafplot(V,-1)
% Stem-leaf plot of V with precision of 100
V = 5000.*randn(1,50);
stemleafplot(V,2)
Jered Wells
01/28/2011
jered [dot] wells [at] duke [dot] edu
@Jered: ROUNDN is not a default function. It is part of the Mapping toolbox, I think if that constraint is specified on your file description, it would improve the quality of this submission.
farfan: ROUNDN is a default MATLAB function. I'm not sure when it was released, but perhaps your version of MATLAB is older than R2008b? Check out the MATLAB documentation for more details: http://www.mathworks.com/help/map/ref/roundn.html
Does what it says. Through me for a loop until I noticed that the input had to be integers. I'd recommend that you have a rounding operation on the input, and a warning if you think it's that important. That way it avoids confusion.
To get higher precision, I'm multiplying the input by 10^3. This would be a nice second input and then mark the results by how far the decimal point is shifted.
Saved me time from trying to make one and can gives more detail then from a histogram. Seems like Stem and Leaf should be a built-in function though...
John, if you're going to leave one-star ratings on someone's work then it's rude not to say why you're doing so. Jared's function does what it says and it has a help section (although no example). It would be nice if it returned the leaf and stem units. Perhaps it's possible to code it with fewer loops, but I've not looked into that carefully.
John, is there something that can be improved? I am open to suggestions. For the data types specified, the program has worked very well for the test data that I have used.