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 版本兼容性
平台兼容性
Windows macOS Linux类别
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.0.0.0 |