MATLAB Feval C# client not working

19 vues (au cours des 30 derniers jours)
Michele Cirella
Michele Cirella le 15 Jan 2019
I need to run MATLAB code in C# application. I have read the official documentation to run MATLAB function in my application.
It works but I have a cache issue. If I run the MATLAB given code in C#:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
// Create the MATLAB instance
MLApp.MLApp matlab = new MLApp.MLApp();
// Change to the directory where the function is located
matlab.Execute(@"cd c:\temp\example");
// Define the output
object result = null;
// Call the MATLAB function myfunc
matlab.Feval("myfunc", 2, out result, 5, 7, "world");
// Display result
object[] res = result as object[];
Console.WriteLine(res[0]);
Console.WriteLine(res[1]);
Console.ReadLine();
}
}
}
with the following matlab function:
function [x,y] = myfunc(a,b,c)
x = a + b;
y = sprintf('Hello %s',c);
If I change x = a+b; in x = a*b; in MATLAB script function, the application continue to return a+b=12 instead of a*b=35.
How to solve this cache issue?

Réponses (0)

Catégories

En savoir plus sur MATLAB Compiler SDK dans Help Center et File Exchange

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by