How to write a class with validators such that I can specify the default values?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sameer Agarkar
am 5 Jul. 2023
Kommentiert: Sameer Agarkar
am 5 Jul. 2023
I want to write a class where I want to fix certain variables with some validators, like {mustBeNumeric} and {mustBePositive} but I want to specify the defualt values which can be updated later. Is there any way to do this?
0 Kommentare
Akzeptierte Antwort
Abhas
am 5 Jul. 2023
Hi Sameer,
There are 2 ways to do this as follows:
1 - You can specify it by assigning a default value along with the validator itself. For example :- {mustBeNumeric} = "defaultValue". But it can only be accessed if the properties of the validators are public.
2 - The alternative way is to use the 'arguments' keyword where you can specify the default values of any validators even if the property is private. You can read more about it here:- https://www.mathworks.com/help/matlab/ref/arguments.html?s_tid=doc_ta
Hope this helps!
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Argument Definitions 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!