什么是存储在单元格中的数据,并存储为双MATLAB中的数据之间的区别? [英] What is the difference between the data stored in a cell and the data stored as double in MATLAB?
本文介绍了什么是存储在单元格中的数据,并存储为双MATLAB中的数据之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个变量,谁长得一模一样给我,但一个是<双>
,另一个是<电池>
。在code看来,它们是由 cell2mat
转换。我的理解是数据存储的问题,但我只是不明白的区别和细胞
和双击
这一点。
I have two variables who look exactly the same to me, but one is <double>
and the other is <cell>
. In the code it seems that they are converted by cell2mat
. I understand it is a question of data storage but I just don't see the difference and the definition of cell
and double
for this.
推荐答案
添加到NRZ的回答,值得注意的是,存储单元阵列时,还有一个额外的内存开销。例如,请考虑以下code:
Adding to nrz's answer, it is noteworthy that there is an additional memory overhead when storing cell arrays. For instance, consider the following code:
A = 1:5
B = {A}
C = num2cell(A)
whos
产生以下输出:
A =
1 2 3 4 5
B =
[1x5 double]
C =
[1] [2] [3] [4] [5]
Name Size Bytes Class Attributes
A 1x5 40 double
B 1x1 152 cell
C 1x5 600 cell
- 你可以从第一行看到,双打基本1 * 5载体
A
需要在内存中40字节(每个双重需要8个字节)。 - 第二行显示,只是包装
A
用单细胞产生B
增加了额外的112个字节。这是在MATLAB单个小区的开销。 - 第三行确认,因为
C
包含5个细胞,并采用(112 + 8)×5 = 600个字节。 - As you can see from the first line, the basic 1-by-5 vector
A
of doubles takes 40 bytes in memory (each double takes 8 bytes). - The second line shows that just wrapping
A
with a single cell to produceB
adds extra 112 bytes. That's the overhead of a single cell in MATLAB. - The third line confirms that, because
C
contains 5 cells and takes (112+8)×5 = 600 bytes.
这篇关于什么是存储在单元格中的数据,并存储为双MATLAB中的数据之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文