image thumbnail

vector to string

version 1.2.0.0 (2.26 KB) by Sven Bossuyt
Converts a vector to a string, using the colon operator to represent linearly spaced subvectors.

650 Downloads

Updated 01 Feb 2010

View License

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.

Cite As

Sven Bossuyt (2022). vector to string (https://www.mathworks.com/matlabcentral/fileexchange/26453-vector-to-string), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!