Problem passing parameter for MATLAB function from .NET
显示 更早的评论
I am trying to communicate between .NET and MATLAB.
I wrote the function in MATLAB and passing parameter from C#.net I caught an Error.
The MATLAB function is
function [out]= tabs(path,x,y,input)
load(path);
d=iddata(y,x,1);
y1=predict(amx,d);
a=y1.y(input);
out =a;
and c#.net code is
TABS.TABS_CLASS obj = new TABS.TABS_CLASS();
string inputx = "{11,12,13,14,15}";
string outputy = "{55,60,65,70,75}";
int pos = 1;
MWNumericArray mwchar = null;
mwchar = (MWNumericArray)(obj.tabs("C:\\5TAB\\TEST.mat", inputx, outputy, pos));
The error is:
MWMCR::EvaluateFunction error: Error using ==> iddata.iddata at 214
Error using ==> lower
Cell elements must be character arrays.Error in =>tabs.m at 3.
after that I changed the code to:
mwchar = (MWNumericArray)(obj.tabs("C:\\5TAB\\TEST.mat", (MWCharArray)inputx, (MWCharArray)outputy, (MWCharArray)pos));
now I get the error:
Unable to cast object of type 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' to type 'MathWorks.MATLAB.NET.Arrays.MWCharArray'.
after that I made this change:
MWCharArray temp;
temp = (MWCharArray)(obj.tabs("C:\\5TAB\\TEST.mat", (MWCharArray)inputx, (MWCharArray)outputy, (MWCharArray)pos));
And see the same error:
Unable to cast object of type 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' to type 'MathWorks.MATLAB.NET.Arrays.MWCharArray'.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Deploy to .NET Applications Using MWArray API 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!