C code to S function multi input multi output block using legacy code
显示 更早的评论
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)
采纳的回答
更多回答(1 个)
sri prakash muniyandi
2014-10-20
1 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Simulink Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!