Filter löschen
Filter löschen

Add class to Scripts

30 Ansichten (letzte 30 Tage)
Vasco
Vasco am 3 Jun. 2020
Kommentiert: Walter Roberson am 3 Jun. 2020
Since R2016B it is possible to create a local function inside a script, reducing the burden of many m files. This is described here: https://nl.mathworks.com/help/matlab/matlab_prog/local-functions-in-scripts.html
How can the same be done with classes? I want to overload a method of an existing class, and plan to use it only in a certain script.
When I try this, matlab R2018b complains about: Illegal use of reserved keyword "classdef".

Antworten (1)

Walter Roberson
Walter Roberson am 3 Jun. 2020
That cannot be done. Class methods can only be defined inside of .m files whose first executable word is classdef
  2 Kommentare
Vasco
Vasco am 3 Jun. 2020
Are there plans to include this feature in any future versions of matlab, like is done for functions? The same motivation as for functions applies.
Walter Roberson
Walter Roberson am 3 Jun. 2020
I have not been told whether there are plans for this. I would not expect it to happen.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by