Main Content

MATLABRuntimeRun-Time Options

What Run-Time Options Can You Specify?

You can pass the options-nojvmand日志文件toMATLAB®Compiler SDK™from a .NET client application using the assembly-level attributesNOJVMandLOGFILE. You retrieve values of these attributes by calling methods of theMWMCRclass to accessMATLAB Runtimeattributes and state.

GettingMATLABRuntimeOption Values Using MWMCR

TheMWMCRclass provides several methods to getMATLAB Runtimeoption values. The following table lists methods supported by this class.

MWMCR Method Purpose
MWMCR.IsMCRInitialized() Returnstrueif theMATLAB Runtimerun-time is initialized, otherwise returnsfalse.
MWMCR.IsMCRJVMEnabled() Returnstrueif theMATLAB Runtimerun-time is started with .NET Virtual Machine (JVM™), otherwise returnsfalse.
MWMCR.GetMCRLogFileName() Returns the name of the log file passed with theLOGFILEattribute.

DefaultMATLABRuntimeOptions

If you pass no options,MATLAB Runtimestarts with default option values:

MATLAB RuntimeRun-Time Option Default Option Values
.NET Virtual Machine (JVM) NOJVM(false)
Log file usage LOGFILE(null)

These options are all write-once, read-only properties.

Use the following attributes to represent theMATLAB Runtimeoptions you want to modify.

MWMCR Attribute Purpose
NOJVM Lets users startMATLAB Runtimewith or without a JVM. It takes a Boolean as input. For example,NOJVM(true)startsMATLAB Runtimewithout a JVM.
LOGFILE Lets users pass the name of a log file, taking the file name as input. For example,LOGFILE("logfile3.txt").

PassingMATLABRuntimeOption Values from a C# Application.Following is an example of howMATLAB Runtimeoption values are passed from a client-side C# application:

[assembly: NOJVM(false), LOGFILE("logfile3.txt")] namespace App1 { class Program { static void Main(string[] args) { Console.WriteLine("In side main..."); try { myclass cls = new myclass(); cls.hello(); Console.WriteLine("Done!!"); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }