matlab中cell array的理解

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中的元素类型不需要统一。

 

 

原文地址:https://www.cnblogs.com/haore147/p/3632855.html