Error CS0246: The type or namespace name `MLApp' could not be found. Are you missing an assembly reference?
I was trying to call Matlab function in C# scripts.
Here is the version of softwares I am using: Matlab: 8.6.0.267246 (R2015b) // Unity 2018.2.2.f1 // Visual Studio 15.7.6
To test the feasibility I set up a simple test code (shown below) added reference "MatlabApplication (Version 8.6) Type Library" and attached it to an empty object. However, I constantly met this compiler error when running this script in Unity.
I would really appreciate it if someone could give me some advice. I am familiar with Matlab but basically a novice in Unity and C# (just self-taught a week ago). Thank you in advance.
namespace MatlabExecution{ public class DanceWithMatlab : MonoBehaviour { public MLApp.MLApp matlab = new MLApp.MLApp();
public DanceWithMatlab()
{
// Step 1:
// Create the MATLAB instance
// Change to the directory where the function is located
matlab.Execute(@"cd C:xx"); // path name is omitted for privacy reason
// Define the output
object result = null;
// Call the MATLAB function
matlab.Feval("Test", 1, out result, 1, 2); // Matlab function name
// Display result
object[] res = result as object[];
Console.WriteLine(res[0]);
//Debug.Log("The result is {0}", res[0]);
matlab.Execute("quit");
}
}
}
Hi there,
I'm trying to do the same (just trying to call a simple matlab function from unity) but getting the same error, do you find a solution in the end?
Hi @unity_421562675 , @unity_3Y-L6RUUZwPSjQ
I am facing the same issue. Did you find a solution to this?,Hi,
I am facing the same issue. Is there another way to call $$anonymous$$ATLAB functions from unity? I tried compiling a dll, but getting some errors in that too when calling from unity.
ey, having the same problem did you ever found a solution? @unity_421562675
Your answer
![](https://koobas.hobune.stream/wayback/20220612172504im_/https://answers.unity.com/themes/thub/images/avi.jpg)