Error in passing parameter for MATLAB function From .net

9 ビュー (過去 30 日間)
Sathiyaseelan
Sathiyaseelan 2011 年 6 月 28 日
Dear all, I was trying to communicate MATLAB with .Net.
I created X and Y variables and Testing values are x=[1,2,3,4,5] and Y=[5,10,15,20,25] and created the model(amx) using Identification Tool. Then saved as .MAT file. The problem is, when I am passing values from C#.net If MATLAB function is like this working fine,
function [out]= test(path, X, Y,pos) load(path); d=iddata(X,Y,1); y1=predict(amx,d); a=y1.y(pos); out =a;
Running Command in MATLAB is,
Test(‘C:\Test\\Tables.mat’,[11;12;13;14;15],[55;60;65;70;75];3)
ans= 15
But answer was based on our created X and Y values, it won’t to consider passing values. So I made change in MATLAB function as,
function [out]= test(path,inputX,outputY,pos) load(path); d=iddata(outputY,inputX,1); y1=predict(amx,d); a=y1.y(pos); out =a;
Now I am facing Error like,
“MWMCR::EvaluateFunction error: Error using ==> idmodel.predict at 111 Mismatch in input/output numbers for model and data.Error in =>passmodel.m at 4.”
C# code is, TABS.TABS_CLASS obj = new TABS.TABS_CLASS();
double[] input = new double[5] { 11, 12, 13, 14, 15 }; double[] output = new double[5] { 55, 60, 65, 70, 75 }; double pos = 2;
MWNumericArray InputX = (MWNumericArray)input;
MWNumericArray OutputY = (MWNumericArray)output;
MWNumericArray mwchar = null; mwchar = (MWNumericArray)obj.test(@"C:\5TAB\5TABS.mat",InputX, OutputY, (MWNumericArray)pos);
Thanks

採用された回答

Rajiv Singh
Rajiv Singh 2011 年 7 月 12 日
Hi Sathiyaseelan, Do you still have a question?
  2 件のコメント
Sathiyaseelan
Sathiyaseelan 2011 年 7 月 13 日
hello,
yup., I want to know about Model Predictive Control(MPC). Actually i am a .net application developer just i want to communicate MPC with .net application. I already done MATLAB Identification Tool with .net but now i can run in MPC in MATLAB but not able to run in .net. It showing error in using predictive keyword.
Rajiv Singh
Rajiv Singh 2011 年 7 月 14 日
You should create a separate thread for your MPC question. Also post more details on your task - what you did, errors you saw and help you need.

サインインしてコメントする。

その他の回答 (1 件)

Sathiyaseelan
Sathiyaseelan 2011 年 7 月 4 日
if we change MATLAB code as, function [out]= test(path, X, Y,pos) load(path); d=iddata(X(:),Y(:),1); y1=predict(amx,d); a=y1.y(pos); out =a; its working fine.

カテゴリ

Help Center および File ExchangeLinear Plant Specification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by