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!