Error using Legacy code: Cannot find a valid lhs expression in the function specification?
Mostra commenti meno recenti
** 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 Commenti
Jan
il 14 Feb 2017
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
il 14 Feb 2017
Walter Roberson
il 19 Gen 2019
the function signature in your h file only has one argument but the function signature in your definition has two parameters .
Risposte (1)
Aman Kalia
il 18 Gen 2019
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.
Categorie
Scopri di più su Environment and Settings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!