Making class accessible without having its .m file in current folder
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Grzegorz Diaczek
el 17 de Nov. de 2022
Comentada: Grzegorz Diaczek
el 17 de Nov. de 2022
MATLAB classdef has been created. I would like to create new objects of this class and share them with other users. It is possible to sent them a .m file with classdef and place it in the special MATLAB folder, that it will be accessible without having the .m file in current folder? I want to let them just open the MATLAB, drag and drop prepared object saved in .mat file to workspace and work on it without selecting the folder where the .m file is defined. Thanks for help.
0 comentarios
Respuesta aceptada
Steven Lord
el 17 de Nov. de 2022
In order to create or work with an instance of the class, it must be accessible to MATLAB. This means it must be in the "current scope", which this documentation page defines as "the current file, an optional private subfolder relative to the currently running function, the current folder, and the MATLAB path."
Class definitions can't be in private folders (see the "No Class Definitions in Private Folders" section on this documentation page) so if you want to be able to call it but not have it be in the current folder it will need to be on the MATLAB search path.
One useful place to put the downloaded class definition would be in their userpath directory which is part of the search path by default.
Más respuestas (0)
Ver también
Categorías
Más información sobre Software Development Tools en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!