A much improved CHAR2LINE

Version 1.0.0.0 (1,56 KB) von Ian Howat
Returns a character array or cellstr as a single, delimited string. Useful for building ascii files.
1,8K Downloads
Aktualisiert 30. Jul 2007

Lizenz anzeigen

CHAR2LINE Make a single spaced or delimited line from a char or cellstr.
B = char2line(A) puts each row of a character array or each cell in a cell array of strings into a single line separated by spaces. If A is a cellstr, the output string will be ordered by rows.
B = char2line(A,'delimiter') separates each string by 'delimiter'.

Example 1:
>> A = char('An','example','of','char2line');
>> char2line(A)
ans =
An example of char2line
Example 2:
>> char2line(A,',')
ans =
An,example,of,char2line
Example 3:
A = repmat(cellstr(A),[1,2])
A =
'An' 'An'
'example' 'example'
'of' 'of'
'char2line' 'char2line'
>> char2line(A)
ans =
An An example example of of char2line char2line

Thanks to jos x for suggestions in improving this function.

Zitieren als

Ian Howat (2025). A much improved CHAR2LINE (https://www.mathworks.com/matlabcentral/fileexchange/15722-a-much-improved-char2line), MATLAB Central File Exchange. Abgerufen.

Kompatibilität der MATLAB-Version
Erstellt mit R2006a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0