Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一堂课(Matlab 2012a,Ubuntu 12.10)
classdef trajectory properties partName; coordinates; end methods end end
如何将属性 partName 限制为集合 {'leftHand','rightHand'} 的元素之一(两者都是字符串)?
您可以使用属性设置方法,例如。
classdef trajectory properties partName; coordinates; end methods function this=set.partName(this,myStr) mySet={'leftHand','rightHand'} ; if any(strcmp(mySet,myStr)) this.partName=myStr; else error('Value not part of set'); end end end end