Documentation Center

  • Trials
  • Product Updates

set

Set property values for audioplayer object

Syntax

set(obj,Name,Value)
set(obj,cellOfNames,cellOfValues)
set(obj,structOfProperties)
settableProperties = set(obj)

Description

set(obj,Name,Value) sets the named property to the specified value for the object obj.

set(obj,cellOfNames,cellOfValues) sets the properties listed in the cell array cellOfNames to the corresponding values in the cell array cellOfValues. Each cell array must contain the same number of elements.

set(obj,structOfProperties) sets the properties identified by each field of the structure array structOfProperties to the values of the associated fields.

settableProperties = set(obj) returns the names of the properties that you can set in a structure array. The field names of settableProperties are the property names.

Tips

The set function allows combinations of property name/value pairs, cell array pairs, and structure arrays in the same function call.

Examples

View the list of properties that you can set for an audioplayer object:

load handel.mat;
handelObj = audioplayer(y, Fs);
set(handelObj)
 

Set the Tag and UserData properties of an audioplayer object using a structure array:

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)

Alternatives

To set the value of a single property, you can use dot notation. Reference each property as though it is a field of a structure array. For example, set the Tag property for an object called handelObj (as created in the Examples):

handelObj.Tag = 'This is my tag.';

This command is exactly equivalent to:

set(handelObj, 'Tag', 'This is my tag.');

See Also

|

Was this topic helpful?