如何从嵌套的细胞中分离数据? [英] How to separate data from nested cells?

查看:174
本文介绍了如何从嵌套的细胞中分离数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个嵌套的单元格下方

I have a nested cell as given below

A= {1x12 cell}  {1x12 cell}  {1x12 cell}  {1x12 cell}  {1x12 cell}

我试过A {:}在上述细胞获取数据,我得到它,如下

I had tried A{:} for getting the data in the above cells and I obtain it as below

ans = 

 Columns 1 through 12

'1'    '0'    '1'    '0'    '1'    '0'    '0'    '1'    '1'    '1'    '1'    '1'



 ans = 

 Columns 1 through 12

'1'    '1'    '0'    '1'    '1'    '1'    '1'    '0'    '1'    '1'    '0'    '0'




 ans = 

 Columns 1 through 12

'0'    '1'    '1'    '1'    '0'    '0'    '0'    '0'    '1'    '1'    '0'    '0'




 ans = 

  Columns 1 through 12

'1'    '1'    '1'    '1'    '0'    '1'    '1'    '0'    '0'    '0'    '0'    '1'




  ans = 

  Columns 1 through 12

'0'    '0'    '1'    '0'    '0'    '1'    '0'    '1'    '0'    '0'    '0'    '1'

我想在存储在变量不同载体每个细胞内的二进制数据。我期望的输出如下,

I want to have the binary data inside each cell in separate vectors stored in variables. My desired output is as follows,

  a1=[1    0    1    0    1    0    0    1    1    1    1    1    ]

  a2=[1    1    0    1    1    1    1    0    1    1    0    0    ]

  a3=[0    1    1    1    0    0    0    0    1    1    0    0    ]

  a4=[1    1    1    1    0    1    1    0    0    0    0    1    ]

  a5=[0    0    1    0    0    1    0    1    0    0    0    1    ]

如何取得这样的成绩?先谢谢了。

How to achieve such a result? Thanks in advance.

推荐答案

您最好使用一个矩阵(由Divakar的建议):

You'd better use a matrix (as suggested by Divakar):

M = reshape(cell2mat([A{:}]),[],numel(A)).';

或者更简单地说,通过knedlsepp指出的:

Or more simply, as noted by knedlsepp:

M = cell2mat(cat(1,A{:}));

然后你想要的变量是 M ,即 M(1:)的行 M(2:)。

这篇关于如何从嵌套的细胞中分离数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆