matlab中class和whos作用

matlab frequently-used function

class

功能

  • 返回給定對象的類型Return class name of object.類似於python中的type函數

語法Syntax

  • S = class(OBJ) %returns the name of the class of object OBJ.

  • Possibilities are:

    double –Double precision floating point number matrix or array
    single –Single precision floating point number array
    logical – Logical array
    char – Character array
    cell – Cell array
    struct – Structure array
    function_handle – Function Handle
    int8 – 8-bit signed integer array
    uint8 – 8-bit unsigned integer array
    int16 – 16-bit signed integer array
    uint16 – 16-bit unsigned integer array
    int32 – 32-bit signed integer array
    uint32 – 32-bit unsigned integer array
    int64 – 64-bit signed integer array
    uint64 – 64-bit unsigned integer array
    class_name – MATLAB class name for MATLAB objects
    java_class – Java class name for java objects
  • Example 1: Obtain the name of the class of value PI

    • name = class(PI);
  • similar function
    See also isa, superiorto, inferiorto, classdef, struct.

其他

  • 更多細節通過doc class查看API

whos

功能

  • List variables in workspace, with sizes and types;比class更加詳細

語法

  • whos:返回當前活動工作空間的所有變量的信息
  • whos(variables):返回指定命名的變量信息
  • whos(location):返回指定位置的變量信息
  • whos(variables,location)
  • S = whos(_):stores information about the variables in structure array, S, using no input arguments, or any of the input arguments from the previous syntaxes.將這些信息複製給結構體變量存儲。

其他

  • 更多細節通過doc whos查看API

以上兩個函數主要用於matlab程序的調試

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章