Making class accessible without having its .m file in current folder
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Steven Lord
2022-11-17
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!