Problem passing parameter for MATLAB function from .NET
Afficher commentaires plus anciens
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'.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Deploy to .NET Applications Using MWArray API dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!