C code to S function multi input multi output block using legacy code
Afficher commentaires plus anciens
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)
Réponse acceptée
Plus de réponses (1)
sri prakash muniyandi
le 20 Oct 2014
1 vote
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.
Catégories
En savoir plus sur Simulink Coder 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!