get
查询 audioplayer
对象的属性值
语法
Value
= get(obj
,Name
)
Values
= get(obj
,{Name1
,...,NameN
})
Values
= get(obj
)
get(obj
)
说明
返回为对象 Value
= get(obj
,Name
)obj
指定的属性的值。
返回 1×Values
= get(obj
,{Name1
,...,NameN
})N
元胞数组中的指定属性的值。
返回包含 Values
= get(obj
)obj
的所有属性值的标量结构体。每个字段名称对应于一个属性名称。
get(
显示所有属性名称及其当前值。obj
)
示例
根据示例文件 handel.mat
创建一个 audioplayer
对象并查询对象属性:
load handel.mat; handelObj = audioplayer(y, Fs); % Display all properties. get(handelObj) % Display only the SampleRate property. get(handelObj, 'SampleRate') % Create a cell array that contains % values for two properties. info = get(handelObj, {'BitsPerSample', 'NumChannels'});
备选方法
要访问单个属性,可以使用圆点表示法。引用每个属性,如同它是结构体数组的字段一样。例如,求出名为 handelObj
的对象(已在“示例”中创建)的 TotalSamples
属性的值:
numSamples = handelObj.TotalSamples;
此命令完全等同于:
numSamples = get(handelObj, 'TotalSamples');