C code to S function multi input multi output block using legacy code
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Paul
el 23 de En. de 2014
Respondida: sri prakash muniyandi
el 20 de Oct. de 2014
Hi I'm trying to create a multi input to multi output, S function in simulink using the legacy code tool.
I am attempting to input three variables
- double trgrqst,
- double VehSp,
- double systmst
Then do some maths on them and return the values (Been trying to use pointers)
- *y1
- *y2
- *y3
basically something looking like this
My C code I wrote is :
C CODE - named ( car.c) _____________________
#include<car.h>
void car(double trgrqst, double VehSp, double systmst, double *y1, double *y2, double *y3) {
*y1 = 1.4 * trgrqst;
*y2 = 1.5 * VehSp;
*y3 = 5 * systmst;
}
_________ END of C code
Header code- named car.h ___________________________
#ifndef car_H
#define car_H
#include "tmwtypes.h"
extern void car(double trgrqst, double VehSp, double systmst, double *y1, double *y2, double *y3);
#endif
______ End of header
I have also included the m script im using to create the s function
My error code is
_italic_Error using legacycode.util.lct_pParseFcnSpec (line 141) Token (or expression) "double trgrqst" not recognized (in "void car(double trgrqst, double VehSp, double systmst, double *y1, double *y2, double *y3);")
Error in legacycode.util.lct_pGetFullInfoStructure (line 38)
Error in legacycode.LCT/generatesfcn (line 22)
Error in legacycode.LCT.legacyCodeImpl (line 55)
Error in legacy_code (line 87) [varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});
Error in Legacy_Script (line 19) legacy_code('sfcn_cmex_generate', def)
0 comentarios
Respuesta aceptada
Kaustubha Govind
el 27 de Mzo. de 2014
As described in the documentation, you cannot used tokens like trgrqst, VehSp, systmst, etc. Legacy Code Tool only knows how to interpret u1, u2, p1, p2, work1, work2, y1, y2 and so on. You may want to change your code to:
def.OutputFcnSpec = 'void car(double u1, double u2, double u3, double *y1, double *y2, double *y3);';
0 comentarios
Más respuestas (1)
sri prakash muniyandi
el 20 de Oct. de 2014
As per the documentation the code should be def.OutputFcnSpec = 'void car(double u1, double u2, double u3, double y1[1], double y2[1], double y3[1]);';. becouse pointers are not allowed in LCT code strctures.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!