MATLAB Object-Oriented Programming

(Joyce) #1
The implicit default value assigned by MATLAB, [0 0 0], conforms to the specified size:

a = ValidateProps

a =

ValidateProps with properties:

Location: [0 0 0]

MATLAB applies scalar expansion when you assign a scalar the Location property.

a = ValidateProps;
a.Location = 1
a =

ValidateProps with properties:

Location: [1 1 1]

MATLAB converts columns to rows to match the size specification:

col = [1;1;1]

col =

1
1
1

a.Location = col

a =

ValidateProps with properties:

Location: [1 1 1]

Colon in Size Specification

A colon in the size specification indicates that the corresponding dimension can have any
length. For example, you can assign a value of any length to the Label property in this
class.

classdef ValidateProps
properties

8 Properties — Storing Class Data

Free download pdf