Not all versions of Matlab are supported, as MxVDev utilizes some of the newer features of Matlab. The drop-down list for Preferred Matlab Version property on the Transform lists the supported versions. If the selected version is not installed, MxVDev defaults to running the latest version detected on the machine.
Also, set the Preferred Matlab Word Size property. The options are 32-bit, 64-bit, or the default, Host Machine.
Use this procedure if the MATLAB version that is currently registered is not the MATLAB version desired. This works for any version of MATLAB that you want to make the default version. However, the version that is used by MxVDev should be later than the version of the original model that is being harnessed. In addition, if MxVDev has already been used to harness the model, the model should be reharnessed so that the new features are usable.
1.Open up a command prompt as administrator.
2.Change the directory to <ProgramFiles>\MATLAB\R2012b\bin directory, where <ProgramFiles> is the appropriate directory for the installation and machine combination:
•Machine 32 bit: C:\Program Files
•Machine 64 bit, Matlab 32 bit: C:\Program Files (x86)
•Machine 64 bit, Matlab 64 bit: C:\Program Files
3.Run the following command:
matlab -regserver -wait -r quit
4.Open the project normally. As explained above, reharnessing may be necessary.
Note that it is possible to install both a 64-bit and a 32-bit version of MATLAB on the same machine.
MxVDev starts Matlab in a very specific manner to ensure that the process can be tracked and that multiple servers can be run simultaneously for multiple Simulink models in the same harness. First, MxVDev enumerates the installed versions on the machine that it is running:
MxVDev searches the registry for installed versions of Matlab, in both the 64-bit and 32-bit registry. The root key is HKLM\SOFTWARE\MathWorks\MATLAB (for 32 bit versions on 64 bit machines, it is HKLM\Wow6432Node\SOFTWARE\MathWorks\MATLAB). Each version of Mat lab's installer places a subkey with the version number (e.g. 2009a will have a key named “HKLM\…\MATLAB\7.8”, 2012b is named “HKLM\...\MATLAB\8.0. In that subkey, there is a string value named “MATLABROOT”, which contains the root installation path of the installation. For example, the default installation of 32 bit 2012b on 32 bit is C:\Program Files\MATLAB\2012b, while a 32 bit installation on a 64 bit machine is C:\Program Files (x86)\MATLAB\2012b. This directory is set by Matlab's installer, which is the reason we do a registry search. After looking at the registry, a version is determined to be installed if the file “matlab.exe” exists in the subdirectory named bin from the directory obtained from the MATLABROOT value.
To start the MATLAB process, the following steps are used:
1.If a specific version is specified in the transform (version and bit width), it has first preference of start. If the specified version does not exist on the machine, the Latest version of Matlab installed is started using the preferred bit width. If the preferred bit width is not installed, the final fallback is the latest version using the bit width of the operating system. For example, a transform may specify that the preferred bit width is 32 bit on a 64 bit machine, meaning that if a 32 bit version of Matlab is installed, it will take precedence over any 64 bit version found.
2.The MATLAB process is started using the executable found above (MATLABROOT\bin\matlab.exe). The command is started with the switch /MLAutomation so that Matlab is set up as an out-of-process COM server.
3.Based upon the version that is started, MxVDev now attempts to activate a COM object to communicate with. The requested COM object is version-specific based upon the version that we believe has been started from above; as different versions of Matlab require requests for different GUIDs.
The above allows MxVDev to support multiple specific versions of Matlab that may exist on the same machine, activates the correct object(s) in the transform harness, allows multiple different versions to be sub processes, and allows MxVDev to track the Matlab processes it starts to detect crashes or errors.
Compatibility (Supported Versions)