How to obtain static member variables in MATLAB classes?

后端 未结 4 1658
名媛妹妹
名媛妹妹 2020-12-03 03:36

Is there a way to define static member variables in MATLAB classes?

This doesn\'t work:

classdef A

    properties ( Static )
        m = 0;
    end
         


        
4条回答
  •  广开言路
    2020-12-03 04:25

    (just to inform) there is (another?) way to create static-like data in matlab

    suppose that you have a "handle" class which its name is "car" if you want the car class to have static data, you could construct another handle class and use it in car class throw composition, the latter class works as a static data for car class

    classdef car

    this way when you create first instance of a car class, an instance of STATIC_DATA_HOLDER will be created and when you create second instance of car class it uses previously created STATIC_DATA_HOLDER class.

    these code tested with "MATLAB 2013b"

提交回复
热议问题