zoukankan      html  css  js  c++  java
  • matlab isfield

    isfield

    函数功能:判断输入是否是结构体数组的域(成员)。

    调用格式:

    tf=isfield(S,'fieldname')

    检查结构体S是否包含由fieldname指定的域,如果包含,返回逻辑1;如果S不包含fieldname域或者S不是结构体类型的,返回逻辑0.

    tf = isfield(S, C)
    其中C是一个包含多个字符串的元胞数组,isfield判定由这些字符串表示的域是否是结构体的域。返回值是逻辑型数组。
    程序示例:
    close all; clear; clc;
     
    student = struct('name', 'John', 'age', 20, 'score', 90);
     
    fprintf('Is ''name'' a field of student structure? %d
    ',isfield(student, 'name'));
     
    fprintf('Is ''salary'' a field of student structure? %d
    ',isfield(student, 'salary'));
     
    isfield(student, {'name', 'salary', 'score'})

    输出结果:

    Is 'name' a field of student structure? 1
     
    Is 'salary' a field of student structure? 0
     
    ans = 1 0 1
     
  • 相关阅读:
    Thread与Handler
    开始机顶盒的生涯
    解决布局被键盘顶的难题
    自动滚动的Textview
    2-解决粘包问题
    1-socket编程
    zipfile模块
    subprocess模块
    day31-异常处理
    collections模块
  • 原文地址:https://www.cnblogs.com/rong86/p/3598041.html
Copyright © 2011-2022 走看看