Main Content

matlab.mixin.SetGetExactNames 类

命名空间: matlab.mixin
超类: matlab.mixin.SetGet

set 和 get 方法要求名称完全匹配

描述

使用 matlab.mixin.SetGetExactNames 类派生继承设置和获取属性值的名为 setget 的方法的类。有关如何使用 setget 方法的信息,请参阅 MATLAB® setget 函数。

matlab.mixin.SetGetExactNames 派生的类要求属性名称区分大小写且精确匹配。要支持不精确的名称匹配,请从 matlab.mixin.SetGet 类派生。

matlab.mixin.SetGetExactNames 类是一个 handle 类。

类属性

Abstract
true
HandleCompatible
true

有关类属性的信息,请参阅类属性

方法

全部展开

示例

全部折叠

定义一个具有两个属性的类。

classdef PropSetGet < matlab.mixin.SetGetExactNames
   properties
      Number {mustBeNumeric} 
      Str string
   end
end

创建该类的一个实例并尝试使用继承的 set 方法设置属性值。该方法失败,因为属性名称必须与类中定义的名称具有区分大小写的匹配。

p = PropSetGet;
set(p,'number',8)
Error using PropSetGetExact/set
The name 'number' is not an accessible property for an instance of class 'PropSetGetExact'.

版本历史记录

在 R2016b 中推出