gpt4 book ai didi

ASP.NET 和 Matlab

转载 作者:行者123 更新时间:2023-12-02 10:30:20 24 4
gpt4 key购买 nike

我已经在 asp.net 中成功开发了一个应用程序,它调用 matlab 函数并以整数形式生成结果...问题是我需要将此值传递回 asp.net 以继续进行进一步的过程重定向哪个页面。

最佳答案

我猜您正在使用 NE Toolbox?

如果是这样,在 C# 中您将这样做。

Matlab函数cellexamp.m:

function out = OutInt
num = 10;
out = { num };

在Matlab中运行deploytool

MATLAB Builder for .NET -> .NET 组件项目/组件名称:MyOutIntProject类名:MyOutIntClass

C#:

using System;
using MathWorks.MATLAB.NET.Utility;
using MathWorks.MATLAB.NET.Arrays;
using MyOutIntProject;

namespace IntTest
{
class CellExampleApp
{
static void Main(string[] args)
{
MWCellArray myIntCell = null;
try
{
MyOutIntClass obj = new MyOutIntClass();
myIntCell = (MWCellArray)obj.OutInt();

MWNumericArray item = (MWNumericArray)cellexp[1];

Console.WriteLine("item is {0}", item);

double[,] native = (double[,])item.ToArray(MWArrayComponent.Real);
Console.ReadLine();
}

catch (Exception exception)
{
Console.WriteLine("Error: {0}", exception);
}
}
}

}

即使您的 num 变量看起来是一个 int,Matlab 也会通过其 MWNumericArray 来回移动所有内容。在这种情况下,您的 native[0,0] 变量将为“10”。

此示例显示 This shows how to use MWArray.dll for moving strings, arrays and ints

关于ASP.NET 和 Matlab,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5471789/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com