主要内容

MathWorks.MATLAB.Runtime.RuntimeOptionAttribute

用于指定在初始化时传递给应用程序的 MATLAB Runtime 选项的 .NET 属性类

自 R2022b 起

描述

使用 RuntimeOption 属性可以指定在初始化时传递给应用程序的 MATLAB® Runtime 选项。

程序集

C:\Program Files\MATLAB\R2025b\extern\dotnet\netstandard2.0\MathWorks.MATLAB.Runtime.dll

C:\Program Files\MATLAB\R2025b\extern\dotnet\netstandard2.0\MathWorks.MATLAB.Types.dll

类详细信息

命名空间:

MathWorks.MATLAB.Runtime
超类:System.Attribute

构造

[assembly: RuntimeOption("option")] 在初始化时将 "option" 传递给应用程序。

参数

option

描述

-nodisplay

隐藏 MATLAB nodisplay 运行时警告。在 Linux® 上,打开不带显示功能的 MATLAB Runtime

-singleCompThread

将 MATLAB 限制为单个计算线程。

-softwareopengl使用 Mesa Software OpenGL® 进行渲染。

C# 示例

using System;
using MathWorks.MATLAB.Runtime;
using MathWorks.MATLAB.Types;
[assembly: RuntimeOption("-singleCompThread")]

namespace MyConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                string ctfPath = @"P:\MATLAB\work\mylinspace.ctf ";
                using (dynamic matlab = MATLABRuntime.StartMATLAB(ctfPath))
                {
                    double[] vec = matlab.mylinspace(1.0, 100.0);
                    foreach (double i in vec)
                    {
                        Console.Write("{0} ", i);
                    }
                }
            }
            catch (MathWorks.MATLAB.Exceptions.MATLABNotAvailableException)
            {
                Console.Error.WriteLine("Could not start MATLAB Runtime.");
            }
            MATLABRuntime.TerminateApplication();
        }
    }
}

版本历史记录

在 R2022b 中推出