A much improved CHAR2LINE

版本 1.0.0.0 (1.6 KB) 作者: Ian Howat
Returns a character array or cellstr as a single, delimited string. Useful for building ascii files.
1.8K 次下载
更新时间 2007/7/30

查看许可证

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.

引用格式

Ian Howat (2024). A much improved CHAR2LINE (https://www.mathworks.com/matlabcentral/fileexchange/15722-a-much-improved-char2line), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2006a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0