Borrar filtros
Borrar filtros

C code to S function multi input multi output block using legacy code

4 visualizaciones (últimos 30 días)
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)
  1. *y1
  2. *y2
  3. *y3
basically something looking like this
I don't seem to be able to get my script to work and I have been trying to work of this Example
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)

Respuesta aceptada

Kaustubha Govind
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);';

Más respuestas (1)

sri prakash muniyandi
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.

Categorías

Más información sobre Simulink Environment Customization en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by