我在Matlab中使用cellstr将字符转换为单元格字符串数组。例如:
A = 'a1a2a3a4...a100'; % I do not list all of the characters in A
B = cellstr(A);
但结果是
B = 'a1a2a3a4a5a6a7a8a9a10a11a12a13a14a15a16a17a18a19a20a21a22a23a24a25a26a27a28a29a30a31a32a33a34a35a36a37a38a39a40a41a42a43a...'
它不会转换所有字符。我猜这是由极限引起的。有谁知道如何增加这个限制?
答案 0 :(得分:0)
它会转换所有字符。省略号来自Matlab,在命令窗口的宽度处截断单元格数组显示的输出。
您可以使用B{1}
显示单元格数组的完整内容:
>> A = sprintf('a%g',1:100);
>> B = cellstr(A)
B =
'a1a2a3a4a5a6a7a8a9a10a11a12a13a14a15a16a17a18a19a20a21a22a23a24a25a26a...'
>> B{1}
ans =
a1a2a3a4a5a6a7a8a9a10a11a12a13a14a15a16a17a18a19a20a21a22a23a24a25a26a27a28a29a30a31a32a33a34a35a36a37a38a39a40a41a42a43a44a45a46a47a48a49a50a51a52a53a54a55a56a57a58a59a60a61a62a63a64a65a66a67a68a69a70a71a72a73a74a75a76a77a78a79a80a81a82a83a84a85a86a87a88a89a90a91a92a93a94a95a96a97a98a99a100
这是单元格字符串的默认格式,这样可以在有限的空间内一次在命令窗口中显示数组的多个元素:
>> [B,B]
ans =
'a1a2a3a4a5a6a7a8a9a10a11a12a1...' 'a1a2a3a4a5a6a7a8a9a10a11a12a1...'
>> [B,B,B]
ans =
'a1a2a3a4a5a6a7a8...' 'a1a2a3a4a5a6a7a8...' 'a1a2a3a4a5a6a7a8...'
但是,所有字符串都包含在单元格数组元素中。对大小的唯一限制是Matlab创建数组所需的内存量。