Mutliple Copies of MATLAB on the same machine -- how to set the default

19 ビュー (過去 30 日間)
Matlab2010
Matlab2010 2013 年 7 月 3 日
編集済み: Tong 2023 年 11 月 29 日
I had 2012A working fine on my machine.
I just installed 2013A.
I have code which automatically launches matlab from task scheduler. All this is is a batch file which contains "start matlab myFunction.m".
Task scheduler is now launching 2013A. I want it to launch 2012A. How do I make it do this? There must be some setting in MATLAB to choose the default version.
Ie I wish to currently have 2012A as the default. At some time in the future I will want 2013A to be the default.
I should also add that simply changing the file association does not work. This does work if you want to manually click on an m file. it does not work if an m file is called from a batch file.
Im running windows 7 pro 64bit

回答 (4 件)

Guru
Guru 2013 年 7 月 3 日
This is an operating system question/task scheduler question and not a MATLAB question.
That being said, simply choose the proper matlab.exe file to run based on the file location. By default, installing a new MATLAB version should not remove the old MATLAB version. Also by default, all your installations should be within:
C:\Program Files\MATLAB
In this folder, you should have a separate folder for each MATLAB installation
  1 件のコメント
Guru
Guru 2013 年 7 月 3 日
Have you tried changing the default application for M-files within Windows?
You can locate a M-file, right click it, and choose Open With... Then you can select to browse for the appropriate MATLAB.exe file.
The M-file association is not MATLAB version dependent. How your computer chooses the application to use for any file type/extension is based on the operating system settings. As Andreas mentioned below, there may be some environment variables or registry settings where this is stored as well, but again this is all from the computer operating system side and NOT MATLAB.

サインインしてコメントする。


Andreas Goser
Andreas Goser 2013 年 7 月 3 日
編集済み: Andreas Goser 2013 年 7 月 5 日
Although cumbersome, you can add the full path of matlab.exe to you batchfile
C:\pathname\matlab.exe -r myFunction.m
If I am not mistaken, the also are ways to add environment variables or registry modifications.
  5 件のコメント
Walter Roberson
Walter Roberson 2023 年 11 月 29 日
You would store the .bat file in any convenient location. You would right-click on the MATLAB icon and set the properties to tell it to execute your chosen .bat file.
Tong
Tong 2023 年 11 月 29 日
編集済み: Tong 2023 年 11 月 29 日
thank you. I just find out the so-called bat file from previous comm. I have 2017b and 2021b and must set 2017b as default.
I just delete the path in User environment, and move the path of 2017b upper than 2021b in System Environment, and it works....

サインインしてコメントする。


Walter Roberson
Walter Roberson 2013 年 7 月 3 日
編集済み: Walter Roberson 2013 年 7 月 3 日
MS Windows uses the registry to decide which MATLAB version to use when asked to open a .m or .fig, or when an application asks to talk via ActiveX to MATLAB.
You can tell MS Windows to use a different version by starting up MATLAB with the -regserver flag.
C:\pathname\matlab.exe -regserver
This only needs to be done once and should hold until you next register a different version (or something corrupts the registry.)
  5 件のコメント
Ken Atwell
Ken Atwell 2013 年 7 月 6 日
And, when you open that DOS window, do so with Admin privilege. See http://www.howtogeek.com/howto/windows-vista/run-a-command-as-administrator-from-the-windows-vista-run-box/ for how to do this.
Walter Roberson
Walter Roberson 2023 年 11 月 29 日
-regserver is still valid as of R2023b, but in the meantime Mathworks also added the function https://www.mathworks.com/help/matlab/ref/regmatlabserver.html to register MATLAB from within MATLAB. It does, however, require that you be executing as administrator, just as @Ken Atwell was right to point out back then.

サインインしてコメントする。


Ken Atwell
Ken Atwell 2013 年 7 月 8 日
See http://www.mathworks.com/help/matlab/matlab_env/associate-files-with-matlab-on-windows-platforms.html for information on how to change the associate from one version of MATLAB to other.
I know you thought Guru's suggestion was unhelpful, but specifying the full path to the specific version of MATLAB you want strikes me a completely reasonable. In your case, the file you want to run is probably
"C:\Program Files\MATLAB\R2012a\bin\matlab"

カテゴリ

Help Center および File ExchangeInstall Products についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by