MATLAB Feval C# client not working

19 views (last 30 days)
Michele Cirella
Michele Cirella on 15 Jan 2019
Edited: Michele Cirella on 16 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?

Answers (0)

Categories

Find more on MATLAB Compiler SDK in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!