比如說你的陣列是A,那麼元素個數可以這樣求解:[m,n]=size(A);NUM=m*n例如;A = 1 1 0 1 1 0 0 1 1 1 0 1 1 1 0 1 0 0 1 1 1 1 0 0 1 1 1 1 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0 0 0 1 1 1 0 0 0 1 1 1 0 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 1 0 1 0 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 0 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1>> [m,n]=size(A);>> NUM=m*nNUM = 144所以,一共有144個元素。
比如說你的陣列是A,那麼元素個數可以這樣求解:[m,n]=size(A);NUM=m*n例如;A = 1 1 0 1 1 0 0 1 1 1 0 1 1 1 0 1 0 0 1 1 1 1 0 0 1 1 1 1 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0 0 0 1 1 1 0 0 0 1 1 1 0 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 1 0 1 0 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 0 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1>> [m,n]=size(A);>> NUM=m*nNUM = 144所以,一共有144個元素。