vector to string
by Sven Bossuyt
22 Jan 2010
(Updated 01 Feb 2010)
Converts a vector to a string, using the colon operator to represent linearly spaced subvectors.
|
Watch this File
|
| File Information |
| Description |
This is a small M-file that can be thought of as the inverse of the colon operator: it takes a linearly spaced row vector and generates a compact notation for that vector.
It handles concatenations of such vectors too, and will in fact for any real array (subject to considerations of numerical precision) generate a valid string representation of that array as a reshaped row vector.
I wrote this because I found myself using input dialog boxes in a GUI, where a numeric vector is entered as a string to be parsed by str2num, and I wanted to provide the current value of the vector as the default answer. mat2str already does this, but the result is unwieldy for all but the smallest arrays, so that was not really useful in this context. |
| MATLAB release |
MATLAB 7.9 (2009b)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 25 Jan 2010 |
* fixed bug where end of one subsequence is start of next one
* added spaces between subsequences, to improve readability
* changed behaviour for subsequences of length 2 |
| 01 Feb 2010 |
generate error immediately if array is not numeric
changed logic of algorithm, to also handle NaN elements
|
|
Contact us at files@mathworks.com