I have several matlab
classes declared. How could I declare constants which are seen in all classes?
For instance: these constants can be physical constants which are used in methods of all classes. The first thing coming to mind is using global variables. Is there any better way? It will be nice to declare these constants in a separate file.
相关问题
- how to define constructor for Python's new Nam
- Extract matrix elements using a vector of column i
- Keeping track of variable instances
- Object.create() bug?
- std::vector of objects / pointers / smart pointers
相关文章
- 接口B继承接口A,但是又不添加新的方法。这样有什么意义吗?
- How do I append metadata to an image in Matlab?
- NameError: name 'self' is not defined, eve
- How can I write-protect the Matlab language?
- Implementation Strategies for Object Orientation
- Check if the Type of an Object is inherited from a
- Rails scope for values only between two dates
- `std::sin` is wrong in the last bit
A class containing the constants is a nice clean way to do this. See the article in Matlab documentation: http://www.mathworks.com/help/matlab/matlab_oop/properties-with-constant-values.html
For example, if you create a class called
NamedConst
as follows:You can reference values with
You can find more details in the link given.