Making class accessible without having its .m file in current folder

4 ビュー (過去 30 日間)
Grzegorz Diaczek
Grzegorz Diaczek 2022 年 11 月 17 日
コメント済み: Grzegorz Diaczek 2022 年 11 月 17 日
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.

採用された回答

Steven Lord
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.
  1 件のコメント
Grzegorz Diaczek
Grzegorz Diaczek 2022 年 11 月 17 日
Thank you for your answer. The solution you proposed will be checked.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by