- Adding a README file with instructions on how to install MyToolbox.
- Using MATLAB's project features to create a startup file that checks for the presence of MyToolbox and provides instructions if it is not found.
How to Add Local Toolbox to Project
13 次查看(过去 30 天)
显示 更早的评论
Hello
I have developed a local toolbox MyToolbox and installed it via the Add-On manager.
Separately, I have a project MyProject that uses MyToolbox. MyProject executes correctly because the functions from MyToolbox are on the MATLAB path because it is installed as an Add-On.
But when I run the dependency analyzer on MyProject I get warnings that all the files called from MyToolbox are from an unreferenced project. My question is, is that okay? Or should MyToolbox be added as a referenced project? If it is to be added as a referenced project, what path should I use? The MyToolxBox code is being called from whatever the default location is that MATLAB stores Add-On files (which is not within the MyProject directory). When I add the referenced project, should I specify an absolute to the Matlab Add-On location?
Or is it okay that it remains as an unreferenced project, and it will somehow be communicated by the MATLAB project files that a requirement of MyProject is that MyToolbox has to be installed?
0 个评论
回答(1 个)
Karanjot
2024-2-6
Hi,
It's technically okay for your project to work without referencing the external toolbox as a project, as long as the toolbox is installed and properly set up on the MATLAB path. However, this setup lacks explicit documentation of dependencies, which can be problematic for maintaining, sharing, or deploying the project.
In case you plan to share the project to collaborate with others, I recommend following Best Practices for MATLAB Toolbox Development. By following these best practices, All files you added when you packaged the toolbox are included in the MLTBX file. When the end users install your toolbox, they do not need to be concerned with the MATLAB path or other installation details. The MLTBX file manages these details for end users.
After packaging the toolbox into a single (.mltbx) installation file, Ensure that users of MyProject know about the dependency on MyToolbox. You should document it in the project. This can be done by:
Here are some links you might find useful:
2 个评论
Karanjot
2024-2-8
Quoting from https://www.mathworks.com/help/matlab/matlab_prog/create-and-share-custom-matlab-toolboxes.html,
"To ensure MATLAB detects the expected components, review the toolbox contents. The following sections of the Package a Toolbox dialog box appear after you select a toolbox folder.
List of the folders and files contained in your toolbox. The listed files and folders are only those files that are located in the top level of the toolbox folder. You cannot navigate through the folders in the Toolbox Packaging dialog box.
By default, if your toolbox contains a P-code file and a MATLAB code file (.m) with the same name in the same folder, MATLAB excludes the .m file from the toolbox. To include both the .p and .m files, clear the Exclude MATLAB script or function files with matching P-files option.
To exclude other files or folders from the toolbox, register them in the text file that is displayed when you click Exclude files and folders. It is good practice to exclude any source control files related to your toolbox."
As for the Path, I believe once a packaged toolbox is installed, you won't need to add the path manually.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!