Error using Legacy code: Cannot find a valid lhs expression in the function specification?
古いコメントを表示
** Error using legacycode.LCT.legacyCodeImpl
> legacy_code('sfcn_cmex_generate', def);
after I use the command to generate sfunction i get the above error:*
Source File:
#include "Controller.h"
double Cout, X;
double controller(double Pout, double Pin)
{
if(Pout>0)
Cout = -X/2;
else
Cout = X/2;
return Cout;
}
Header File:
#ifndef _CONTROLLER_H_
#define _CONTROLLER_H_
double contr(double Pout);
#endif
| *
def.SourceFiles = {'Controller.c'};
def.HeaderFiles = {'Controller.h'};
def.SFunctionName = 'ex_sfun_controller';
def.OutputFcnSpec = 'double y = controller(double u1,double u2)';
legacy_code('sfcn_cmex_generate', def);*|
How to resolve this error?
3 件のコメント
Jan
2017 年 2 月 14 日
Did you notice, that your code is not readable? Please consider http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup .
Gaurav Agarwal
2017 年 2 月 14 日
Walter Roberson
2019 年 1 月 19 日
the function signature in your h file only has one argument but the function signature in your definition has two parameters .
回答 (1 件)
Aman Kalia
2019 年 1 月 18 日
Hey Gaurav,
I was running into the same issue and found the error I was making. In your def.OutputFcnSpec you need to make sure that output and input variables are represented correctly. In your case, replace def.OutputFcnSpec in your code with the following:
def.OutputFcnSpec = 'double y1 = controller(double u1,double u2)';
Basically change y to y1 and it should work. For passing parameters use p1, p2 , p3 and so on.
Hope this helps.
カテゴリ
ヘルプ センター および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!