计算矩阵内存消耗

Tho*_*oth 2 matlab

是否有任何Matlab函数可以返回矩阵消耗的DRAM内存量?当然还有经典的方式,纠正我,如果我错了,MemSize = numel(myMatrix)*BytesPerElement在那里 BytesPerElement = 4,如果我们有双重工作,或者 BytesPerElement = 1,如果我们单工作.当然,如果没有这样的功能,可以建议他自己的方式来计算字节中的内存.兆字节或千兆字节.

谢谢.

Edr*_*ric 5

您可以使用WHOS的程序化形式:

>> x = rand(1024);
>> w = whos

w = 

      name: 'x'
      size: [1024 1024]
     bytes: 8388608
     class: 'double'
    global: 0
    sparse: 0
   complex: 0
   nesting: [1x1 struct]
persistent: 0
Run Code Online (Sandbox Code Playgroud)