MATLAB OOP - redefine static method
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi folks,
Following is an OOP question from a guy who knows nothing about OOP, so excuse me in advance :)
There is a built-in MATLAB class, located in matlabroot/toolbox/coder/connectivity/+coder/+rtiostreamtest/Parameters.m (if your version of MATLAB is earlier than R2012b, you might not find it). This class defines a method called getParameterInstance as Static. I just need to add another case to switch statement in this method. I don't want to modify the shipping MATLAB file, and i heard you can "subclass" those shipping classes.
Following documentation, i created a subclass like this:
classdef Parameters < coder.rtiostreamtest.Parameters
methods (Static)
function instance = getParameterInstance(tag, input)
..my very own version of switch-case..
end
end
end
This subclass is located in +myclass/Parameters.m file in MATLAB path. I then issued "rehash toolbox", just in case.
However, i don't see any effect. I'm not overriding the static method of coder.rtiostreamtest.Parameters class.
What am i doing wrong?
Many thanks!
3 Kommentare
Akzeptierte Antwort
per isakson
am 8 Jul. 2013
Bearbeitet: per isakson
am 8 Jul. 2013
Do you use a call like this?
myclass.Parameters.getParameterInstance( 'two', 'args' )
4 Kommentare
per isakson
am 8 Jul. 2013
Bearbeitet: per isakson
am 8 Jul. 2013
I don't have access to the Embedded Coder toolbox.
Had the call in the "rtiostreamtest script" been
Parameters.getParameterInstance( 'two', 'args' )
it would have been possible to put a class named Parameters in the top of the Matlab search path. (Not in a package.)
Yes, you will probably need to modify the Matlab script, which should be avoided:-(.
AFAIK: the term built-in class does not include m-files, i.e. not code written in the Matlab language. However, I cannot find a proper definition in the documentation.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Software Development Tools finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!