set
设置 audioplayer 对象的属性值
语法
set(obj,Name,Value)
set(obj,cellOfNames,cellOfValues)
set(obj,structOfProperties)
settableProperties = set(obj)
说明
set( 将对象 obj,Name,Value)obj 的给定属性设置为指定值。
set( 将元胞数组 obj,cellOfNames,cellOfValues)cellOfNames 中列出的属性设置为元胞数组 cellOfValues 中的相应值。每个元胞数组必须包含相同的元素数。
set( 将结构体数组 obj,structOfProperties)structOfProperties 的每个字段标识的属性设置为关联字段的值。
返回可在结构体数组中设置的属性的名称。settableProperties = set(obj)settableProperties 的字段名称为属性名称。
示例
查看可为 audioplayer 对象设置的属性列表:
load handel.mat; handelObj = audioplayer(y, Fs); set(handelObj)
使用以下结构体数组设置 audioplayer 对象的 Tag 和 UserData 属性:
newValues.Tag = 'My Tag';
newValues.UserData = {'My User Data', pi, [1 2 3 4]};
load handel.mat;
handelObj = audioplayer(y, Fs);
set(handelObj, newValues)
% View the values all properties.
get(handelObj)提示
set 函数允许在同一函数调用中使用属性名称/属性值对组、元胞数组对组和结构体数组的组合。
备选方法
要设置单个属性的值,可以使用圆点表示法。引用每个属性,如同它是结构体数组的字段一样。例如,设置名为 handelObj 的对象(已在“示例”中创建)的 Tag 属性:
handelObj.Tag = 'This is my tag.';
此命令完全等同于:
set(handelObj, 'Tag', 'This is my tag.');