C code to S function multi input multi output block using legacy code
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Paul
il 23 Gen 2014
Risposto: sri prakash muniyandi
il 20 Ott 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155502/image.png)
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 Commenti
Risposta accettata
Kaustubha Govind
il 27 Mar 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 Commenti
Più risposte (1)
sri prakash muniyandi
il 20 Ott 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 Commenti
Vedere anche
Categorie
Scopri di più su Simulink Environment Customization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!