MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   将1 x N数组合并为1 x 1数组,而无需在MATLAB中使用循环 (https://www.labfans.com/bbs/showthread.php?t=22823)

poster 2019-12-10 16:49

将1 x N数组合并为1 x 1数组,而无需在MATLAB中使用循环
 
我有一个1 x N的双数组,我想将其合并为1 x 1的数组。

例如K = [0,1,1,1];

我希望K成为K = [0111];

我该怎么做?


回答:
这是一种可爱的方法,可以一行完成:

>> K = [1 2 3 4]; >> K*10.^(length(K)-1:-1:0)' ans = 1234 编辑:新的,超级短的方式。



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


所有时间均为北京时间。现在的时间是 23:22

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