Running/testing scripts on multiple Matlab/Simulink versions?

11 vues (au cours des 30 derniers jours)
Monika Jaskolka
Monika Jaskolka le 10 Mar 2020
Modifié(e) : Walter Roberson le 30 Jan 2025 à 20:32
I do a lot of script and tool development for Matlab/Simulink. This involves supporting multiple versions of Matlab, usually from R2016a+ (previously it was R2011b+). This means that I have almost a dozen different versions of Matlab installed on my computer. When one of my tools/scripts encounters a bug in a version of Matlab, or the Matlab/Simulink behaviour differs between versions, I need to be able to pinpoint which version the bug occurred in or the behaviour changed in. I usually can't find the bugs listed on the Bug Reports support page, especially when the bugs are already fixed in later versions. Likewise, when the behaviour changes I check if it is noted in the Release Notes, but these are very high-level descriptions and I usually can't find it mentioned.
Given that the aforementioned pages are not reliable, I usually need to figure out which version of Matlab has the bug fix or behaviour change. I typically follow this process:
  • I create a script to replicate the bug automatically (if possible).
  • One by one I open each version of Matlab, execute the script, and make note of when the bug occurs. Sometimes I have to download and install additional Matlab versions.
  • Then I develop a workaround for the bug or behaviour change by having the script check which version it is running on, and then perform extra steps to fix the buggy behavior or accommodate for inconsistent behaviours between the versions.
My questions is: Is it possible run a script on multiple versions of Matlab in order to make this process a little easier?

Réponse acceptée

Peter O
Peter O le 11 Mar 2020
Modifié(e) : Walter Roberson le 30 Jan 2025 à 20:32
MATLAB can run in a headless mode from the command line, where it can take a script to execute. It's been a while since I've done it, but I believe you start it with a -nojvm and a -nodisplay flag, and there might be a few other things. This post outlines a lot of it:
I'd imagine you can draw from a list of the binary locations for each release. From my experience, Simulink should also work this way, being called from headless (which is basically what the parallel toolbox workers do).
If you want to get really crazy, you can even use the "!" character to make system cmdline calls from within a supervisory MATLAB script, and catch everything in a try/catch or pipe problems over to stderr. Who needs a pesky script in bash or powershell!

Plus de réponses (1)

Jianfei
Jianfei le 30 Jan 2025 à 15:42
Modifié(e) : Jianfei le 30 Jan 2025 à 15:46
I searched for this question years ago, and recently, I found my own solution, which I’m quite satisfied with. Here’s what I did:
  1. I created a function test class to test all my functions. It saves test result files and records pass/fail statuses along with result file links in an Excel sheet.
  2. I wrote a Python function to open different versions of MATLAB and run tests sequentially.
  3. I created a VBS file to execute the Python function.
Now, all I need to do is:
  1. Double-click the VBS file.
  2. Enter the function name in the popup dialog, and the tests will run automatically in all MATLAB versions.
  3. Check my Excel sheet for test results.
  1 commentaire
Steven Lord
Steven Lord le 30 Jan 2025 à 16:20
This may be overkill for your use case, but you might be interested in the Continuous Integration (CI) functionality documented on this page.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Install Products dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by