zoukankan      html  css  js  c++  java
  • 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中的元素类型不需要统一。

     

     

  • 相关阅读:
    webstrom破解的问题
    redis高级应用(1)
    linux之软链接、硬链接
    爬虫之scrapy、scrapy-redis
    爬虫之xpath、selenuim
    爬虫之Beautifulsoup模块
    爬虫之Reuqests模块使用
    测试项目配置
    Cleary基础
    Redis基础
  • 原文地址:https://www.cnblogs.com/haore147/p/3632855.html
Copyright © 2011-2022 走看看