MATLAB Answers

Toolbox export using 19a style project files

10 views (last 30 days)
Peter Corke
Peter Corke on 1 Oct 2019
Commented: Robert on 4 Feb 2021 at 10:33
I'm very confused about these new project files. I have a .prj file that I've used for ages to package my code into a .mltbx file. With 19a we have what looks like a different sort of project file, also with the .prj extension. They do have different icons in the MATLAB file browser, but the documentation seems to treat the term "project file" interchangeably.
The new project file seems like a useful improvement, it knows all about the project, what files are included etc. I don't see why we need both kinds of project file.
If I use the programmatic interface (matlab.addons.toolbox.packageToolbox) to package my toolbox it will only work with the first sort of .prj file, not the second sort - that generates the error message "Invalid MATLAB toolbox project".
My questions:
  • is it proper to call both of these file types "project files"? The documention does.
  • when adding or subtracting files to my project do I have to update both files? The 19a project file can export the sort of project file that can be used for packaging (ToolboxPackagingConfiguration.prj), but that exported file is missing all the metadata (image, author, description etc.) which should logically live in the 19a style project file.
  • what's the rationale for having two files? Could all the information about my project, including how to package it (ie. the metadata) live in the one file?


Sign in to comment.

Answers (1)

Gavin Walker
Gavin Walker on 5 Oct 2019
In R2019a we introduced Projects to MATLAB --
A lot of this functionality will be familiar to Simulink users, who've had access to these capabilities for many releases under the old name of "Simulink Projects". A project is used to set up and manage your MATLAB environment: it contains all the files you need for your work and it can set-up (and tear down) your MATLAB path automatically. It includes file dependency analysis capabilities that let you see how your project is structured, check for missing files and see what toolboxes it needs.
And projects have a lot of other capabilities to support working across a team like nice integration with source control tools, proejct shortcuts to help others find the important files in your project and project labels that let you add more information to the project about what specific files do. For example, when those labels are used to define which of your files are tests, then other featues, like runtests ( can find and run those tests automatically.
So a project is the place where you develop things. It has all your source code, your tests, requirements and so on. If you want to share this with a collegue who is going to help develop it with you (or perhaps test it), then you can share the whole project with them, usually via a source control repository.
When you want to share your work with someone else who just wants to use it, not develop it, then it might make sense to package it as a toolbox and create an MLTBX file. This can be done right from the project from the "share" button. Likely, the toolbox will not include all the files in the project (you might strip out the tests and requirements files, for example) and those same project labels can help here, too. ( )
To answer your other question, today you have to manually keep the two different definitions (files in my project; subset I want to package as a toolbox) up-to-date manually but this is really helpful feedback for us as we continue to develop these features.


Peter Corke
Peter Corke on 9 Oct 2019
The last para is useful to me, thanks, but some of my questions are still unanswered.
What do you call these two different definitions, are they both "project files" ? It's not unreasonable to expect that a given software system keeps different types of information in files with different extensions, but here we have .prj files that hold different information used for different purposes. This is the nub of the confusion.
Why is the metadata used for sharing (thumbnail image, short description, author contact details etc.) kept in the 19a project file?
Todd Flanagan
Todd Flanagan on 9 Oct 2019
First things first, your existing workflow should be unchanged. You just need to not pass these new prj files into toolbox packaging code.
MATLAB has recognized different project file formats for different purposes for many years. These workflows tended to operate in isolation so most people didn’t find themselves in the situation you noticed. Both of the prj files are project files and have always used the prj extension. When projects were brought into MATLAB, we had to balance some confusion against compatibility and we chose to prioritize compatability. As Gavin said above, we continue to develop these features and expect that the overall experience will improve over time.
Robert on 4 Feb 2021 at 10:33
@Todd Flanagan Is there a way to identify what type of project a file is programmatically?

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!

Translated by