How does code sharing work in MATLAB?

6 ビュー (過去 30 日間)
John Smith
John Smith 2022 年 3 月 1 日
回答済み: Steven Lord 2025 年 1 月 29 日
I have a small MATLAB project that I would like to use in many other MATLAB projects. And, I want to do this programmatically (as part of a build pipeline) instead of any sort of manual installation.
Typically, In Java world, for a similar situation, this is how it usually works:
  1. I create a jar file out of this project that I want to share with other projects
  2. I then push that jar file to a maven repository with a particular version as part of the build process (either hosted internally in an organization or an outside maven repository)
  3. Other projects can then specify a particular version as a dependency for this jar in their pom.xml file and that is how the code gets available to them
What is the equivalent of workflow for above in MATLAB world?

回答 (2 件)

Shaunak
Shaunak 2025 年 1 月 29 日
編集済み: Shaunak 2025 年 1 月 29 日
Hi John,
It is my understanding that you are looking to package and distribute your MATLAB code for reuse in other projects.
You can package the MATLAB code into a toolbox using the 'Toolbox Packaging' app or a script, then distribute it via MATLAB File Exchange or an internal server.
By following these steps, code can be effectively packaged and shared among users:
  1. Create a MATLAB Toolbox: Use the 'Toolbox Packaging' app or automate the process with a script to create a toolbox to share with others. These files can include MATLAB code, data, apps, examples, dependencies, and documentation. When you create a toolbox, MATLAB generates a single installation file (MLTBX) that enables you or others to install your toolbox.
  2. Distribute the Toolbox: Host the packaged MLTBX file on MATLAB File Exchange or an internal server for easy access and installation by others.
The following links can be used for further reference:
Hope this helps.

Steven Lord
Steven Lord 2025 年 1 月 29 日
Some of the functionality listed in the Software Development Tools category in the MATLAB documentation was not available in 2022, but if you're interested in this workflow in more recent releases of MATLAB I recommend reviewing the Build Automation, Continuous Integration (CI), and Package Management sections linked from that documentation page.

カテゴリ

Help Center および File ExchangeProject File Management についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by