1. matlab中有一個函數iscell() 用於判斷一個數組是不是cell array
參考:MATLAB Function Reference
iscell
Determine whether input is cell array
Syntax
tf = iscell(A)
Description
tf = iscell(A) returns logical 1 (true) if A is a cell array and logical 0 (false) otherwise.
Examples
A{1,1} = [1 4 3; 0 5 8; 7 2 9];
A{1,2} = 'Anne Smith';
A{2,1} = 3+7i;
A{2,2} = -pi:pi/10:pi;
iscell(A)
ans =
1
2.那什么是cell array呢?
Examples
This example creates a cell array that is the same size as another array, A.
A = ones(2,2)
A =
1 1
1 1
c = cell(size(A))
c =
[] []
[] []
The next example converts an array of java.lang.String objects into a MATLAB cell array.
strArray = java_array('java.lang.String', 3);
strArray(1) = java.lang.String('one');
strArray(2) = java.lang.String('two');
strArray(3) = java.lang.String('three');
cellArray = cell(strArray)
cellArray =
'one'
'two'
'three'
做一個類比:在java中,我們傳遞參數時特別喜歡用object定義參數類型,這樣做的好處是:可以保持接口的統一。
這里cell array:首先是一個array,其次array中的元素類型不需要統一。
