在C语言中获取字节数的函数是sizeof,而在matlab中获取字节的办法就是用whos函数
使用:help whos,即可以得到相关的whos的介绍,其中一种用法是
S = WHOS(...) returns a structure with the fields:
name -- variable name
size -- variable size
bytes -- number of bytes allocated for the array
class -- class of variable
global -- logical indicating whether variable is global
sparse -- logical indicating whether value is sparse
complex -- logical indicating whether value is complex
nesting -- struct with the following two fields:
function -- name of function where variable is defined
level -- nesting level of the function
persistent -- logical indicating whether variable is pe
举例:获取字符串的字节数
str='abc';
s=whos(str);
byte=s.bytes;%即可以获得字节数,为6