MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   将单元格数组中的双精度插入MATLAB中的向量 (https://www.labfans.com/bbs/showthread.php?t=23173)

poster 2019-12-10 20:30

将单元格数组中的双精度插入MATLAB中的向量
 
如何在不使用'for'循环的情况下,将包含双打的单元格数组的第一行插入到向量中?



[B]回答:[/B]

您可以使用花括号[URL="http://www.mathworks.com/help/techdoc/matlab_prog/br04bw6-117.html"]将单元格数组[/URL]中的[URL="http://www.mathworks.com/help/techdoc/matlab_prog/br04bw6-117.html"]条目[/URL]作为[URL="http://www.mathworks.com/help/techdoc/matlab_prog/br2js35-1.html"]逗号分隔的列表[/URL] ,然后使用方括号将这些值收集到行向量中。这是一个例子:

>> C = num2cell(magic(5)) %# A sample cell array C = [17] [24] [ 1] [ 8] [15] [23] [ 5] [ 7] [14] [16] [ 4] [ 6] [13] [20] [22] [10] [12] [19] [21] [ 3] [11] [18] [25] [ 2] [ 9] >> vec = [C{1,:}] %# Put the first row in a vector vec = 17 24 1 8 15

[url=https://stackoverflow.com/questions/2374706]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 11:00

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.