| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
You can see the names of all public object properties using the properties function with the object's class name or with an actual object. For example:
>> properties('MException')
Properties for class MException:
identifier
message
cause
stackAfter creating an object, you can access the values of its properties:
try a = rand(4); a(17) = 7; catch me % catch creates an MException object named me disp(['Current error identifier: ' me.identifier]) end Current error identifier: MATLAB:indexed_matrix_cannot_be_resized
Access the data in properties using dot notation:
object.PropertyName
For example, you can access the message property of the MException object, me, with this syntax:
>> me.message ans = In an assignment A(I) = B, a matrix A cannot be resized.
See Capturing Information About the Error for more information on using MException objects.
Objects often restrict what values you can assign to them. For example, the following timeseries object has 10 data values, each corresponding to a sample time:
tsobj = timeseries(rand(10,1),1:10,'Name','Random Sample');
Now suppose you attempt to set the Data property to a three-element vector:
>> tsobj.Data = [1 2 3];
??? Error using ==> timeseries.timeseries>timeseries.set.Data at 171
Size of the data array is incompatible with the time vector.The timeseries class design ensures that the number of data samples matches the number of time samples. This illustrates one of the advantages a specialized object has over a general purpose-data structure like a MATLAB struct.
![]() | Creating Objects | Calling Object Methods | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |