zoukankan      html  css  js  c++  java
  • 单元数组

    1. 可以采用大括号({})建立单元数组,也可以采用cell()

    1 clear all;
    2 c = {'中国','China';[1:4],100};
    3 c{1,1}
    4 c{1,2}
    5 c{2,1}
    6 c{2,2}
    7 c

    结果:

    ans =

    中国


    ans =

    China


    ans =

    1 2 3 4


    ans =

    100


    c =

    '中国' 'China'
    [1x4 double] [ 100]

    2、 cell(N): 产生一个N*N的空单元数组

      cell(M,N): 产生一个M*N 的单元数组

      cell(M,N,P,....): 产生一个M*N*P阶的空单元数组

      cell(size(A)): 该函数产生和A维数相同的空单元数组

    3、 函数celldisp()

      celldisp(C): 该函数显示单元型变量C的内容

      celldisp(C,'name'): 采用名称name来显示单元型变量C的内容

    例子:

    1 clear all;
    2 c = {'中国','China';[1:4],100};
    3 celldisp(c);
    4 celldisp(c,'mycell');

    结果:

    c{1,1} =

    中国


    c{2,1} =

    1 2 3 4



    c{1,2} =

    China


    c{2,2} =

    100



    mycell{1,1} =

    中国


    mycell{2,1} =

    1 2 3 4



    mycell{1,2} =

    China


    mycell{2,2} =

    100

    3、函数cellplot()

      H = cellplot(C): 显示单元变量C,返回值为一个向量,体现了表面、线和句柄等

      H = cellplot(C,'legend'): 显示单元型变量C,并为图形添加注释legend

     例子:

    1 clear all;
    2 c = {'中国','China';[1:4],100};
    3 subplot(1,2,1);
    4 out = cellplot(c,'legend');
    5 subplot(122);
    6 out2 = cellplot(c);
    7 out
    8 out2 

    结果:

    out =

    174.0048
    175.0043
    176.0043
    177.0043
    178.0043
    179.0043
    180.0043
    181.0043


    out2 =

    211.0048
    212.0043
    213.0043
    214.0043
    215.0043
    216.0043
    217.0043
    218.0043

  • 相关阅读:
    Django-url反向解析和命名空间
    django-分页paginator
    python-命令模式
    python-访问者模式
    python-责任链模式
    python-备忘录模式
    最长无重复字串
    计算机网络常见面试题
    C++对象模型
    原码反码补码(转)
  • 原文地址:https://www.cnblogs.com/Bro-Young/p/6111539.html
Copyright © 2011-2022 走看看