matlab中cell array的理解

时间:2014-03-30 00:01:57   收藏:0   阅读:685

1. matlab中有一个函数iscell() 用于判断一个数组是不是cell array

参考:MATLAB Function Reference

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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呢?

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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中的元素类型不需要统一。

 

 

matlab中cell array的理解,布布扣,bubuko.com

原文:http://www.cnblogs.com/haore147/p/3632855.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!