How to programmatically get custom MATLAB toolbox version?

12 Ansichten (letzte 30 Tage)
I have created my own toolbox and packaged it into a .mltbx file. Inside the toolbox, I want to include a function that returns the current version of the toolbox installed on the user's computer. Is there a way to do extract this information programmatically from either the .mltbx file or .prj file?

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 5 Feb. 2016
The version info of your toolbox should really come from the contents of your toolbox source code. Provide a Contents.m file in your toolbox to specify the version of your toolbox. Search the MATLAB document for Contents.m to find out how to specify the version info. There is also a way to auto generate the Contents.m file to provide a function summary of your toolbox. After your toolbox is installed by a user, the user can use ver('toolbox_name') to find out the version and date of your toolbox.
The .mltbx file is a packaged installation file for your toolbox. You could provide the version info (it is best to be the same as what is specified in the Contents.m file) as you pack it. But the user should really get the version info from the provided Contents.m file using the ver() command.
  2 Kommentare
Matthew Eicholtz
Matthew Eicholtz am 5 Feb. 2016
Ah yes, the Contents.m file. Thanks for the suggestion. I will go that route, although I am still curious if it is possible to parse the .mltbx file for this info since you have to insert that field when you package the toolbox. I like the idea of specifying the version in only one place.
per isakson
per isakson am 13 Feb. 2021
Bearbeitet: per isakson am 21 Feb. 2021
See: matlab.addons.toolbox.toolboxVersion - Query or modify version of toolbox (Introduced in R2016a). Doc says: "Assume that you have the myToolbox.mltbx toolbox file on your MATLAB® search path. Query the version number."
"current version of the toolbox installed on the user's computer" toolboxVersion() doesn't help, since the toolbox file most likely isn't on the search path of the user's system.
"I like the idea of specifying the version in only one place." Yes, that's important.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by