主要内容

本页采用了机器翻译。点击此处可查看英文原文。

get

访问模型属性值

语法

Value = get(sys,'PropertyName')
Struct = get(sys)

说明

Value = get(sys,'PropertyName') 返回模型对象 sys 中属性 PropertyName 的当前值。'PropertyName' 可以是完整属性名(例如 'UserData'),或任何不存在歧义且不区分大小写的缩写(例如 'user')。请参阅各个模型对象类型的参考页面,以获取该模型可用的属性列表。

Struct = get(sys) 将 TF、SS 或 ZPK 对象 sys 转换为标准的 MATLAB® 结构,其中属性名称作为字段名称,属性值作为字段值。

没有左侧参量,

get(sys)

显示 sys 的所有属性及其值。

示例

全部折叠

创建以下离散时间单输入单输出传递函数模型:

H(z)=1z+2

将采样时间设置为 0.1 秒,并将输入通道名称输入为 Voltage

h = tf(1,[1 2],0.1,'InputName','Voltage')
h =
 
  From input "Voltage" to output:
    1
  -----
  z + 2
 
Sample time: 0.1 seconds
Discrete-time transfer function.
Model Properties

显示传递函数的所有属性。

get(h)
       Numerator: {[0 1]}
     Denominator: {[1 2]}
        Variable: 'z'
         IODelay: 0
      InputDelay: 0
     OutputDelay: 0
       InputName: {'Voltage'}
       InputUnit: {''}
      InputGroup: [1×1 struct]
      OutputName: {''}
      OutputUnit: {''}
     OutputGroup: [1×1 struct]
           Notes: [0×1 string]
        UserData: []
            Name: ''
              Ts: 0.1000
        TimeUnit: 'seconds'
    SamplingGrid: [1×1 struct]

显示传递函数的分子。

num = get(h,'Numerator')
num = 1×1 cell array
    {[0 1]}

分子数据以元胞数组形式存储,因此 Numerator 属性是一个包含行向量 [0 1] 的元胞数组。

num{1}
ans = 1×2

     0     1

显示传递函数的采样时间 Ts

get(h,'Ts')
ans = 
0.1000

或者,使用点表示法访问属性值。

h.Ts
ans = 
0.1000

提示

语法的替代项

Value = get(sys,'PropertyName')

是类结构体引用

Value = sys.PropertyName

例如,

sys.Ts
sys.A
sys.user

返回(状态空间)模型 sys 的采样时间、A 矩阵和 UserData 属性的值。

版本历史记录

在 R2006a 之前推出