Code covered by the BSD License  

Highlights from
mat2colon

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 1.99 KB File ID: #30797

mat2colon

by Javier Lopez-Calderon

 

18 Mar 2011

Converts a matrix (row x col) into a string using MATLAB colon notation (single resolution).

| Watch this File

File Information
Description

Usage: strMat = mat2colon(Matrix, options)

 Options are:

 'Delimiter' - 'on','yes','off','no' {default on} : Including square brackets []
                    (or curly brackets {} when output's dimensions are not consistent)
                    'auto' by default.
 'Sort' - 'on','yes','off','no' {default off} : Sort elements in ascending order
                    
 'Class' - MATLAB classes

 'Repeat' - 'on','yes','off','no' {default on} : Keep repeated elements

 Same as vect2colon but matrix capability

 Example 1
 
 mat2colon([14 12 10 8 6 4 2; 34 -23 0 1 45 46 47; 5 5 5 5 5 5 5])
 ans =
 
 [ 14:-2:2; 34 -23 0 1 45:47; 5 5 5 5 5 5 5]
 
 Example 2

 mat2colon([14 12 10 8 6 4 2; 34 -23 0 1 45 46 47; 5 5 5 5 5 5 5], 'Repeat', 'no')
 ans =
 
 {[ 14:-2:2];[ 34 -23 0 1 45:47];[ 5]}

 See also: vect2colon, eval, str2num

 Feedback is appreciated.

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
18 Mar 2011 Javier Lopez-Calderon

I forgot to mention that mat2colon.m needs vect2colon.m in order to work. You can find it here http://www.mathworks.com/matlabcentral/fileexchange/22076

21 Mar 2011 Bruno Luong

I suggest to merge the two submissions mat2colon and vec2colon into one.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
matrix Javier Lopez-Calderon 18 Mar 2011 15:59:42
string Javier Lopez-Calderon 18 Mar 2011 15:59:42
colon Javier Lopez-Calderon 18 Mar 2011 15:59:42
vect2colon Javier Lopez-Calderon 18 Mar 2011 15:59:42

Contact us at files@mathworks.com