About how to generate C header files with MATLAB scripts.
이전 댓글 표시
Hi guys:
I have a question about how to generate some C datatypes with *.m in which buses/enumerations are defined.
For example, I have a script looks like this:
function bus()
% BUS initializes a set of bus objects in the MATLAB base workspace
% Bus object: Bus1
clear elems;
elems(1) = Simulink.BusElement;
elems(1).Name = 'a';
elems(1).Dimensions = 1;
elems(1).DimensionsMode = 'Fixed';
elems(1).DataType = 'double';
elems(1).SampleTime = -1;
elems(1).Complexity = 'real';
elems(1).Min = [];
elems(1).Max = [];
elems(1).DocUnits = '';
elems(1).Description = '';
elems(2) = Simulink.BusElement;
elems(2).Name = 'a1';
elems(2).Dimensions = 1;
elems(2).DimensionsMode = 'Fixed';
elems(2).DataType = 'double';
elems(2).SampleTime = -1;
elems(2).Complexity = 'real';
elems(2).Min = [];
elems(2).Max = [];
elems(2).DocUnits = '';
elems(2).Description = '';
Bus1 = Simulink.Bus;
Bus1.HeaderFile = 'bus.h';
Bus1.Description = '';
Bus1.DataScope = 'Exported';
Bus1.Alignment = -1;
Bus1.Elements = elems;
clear elems;
assignin('base','Bus1', Bus1);
Then I'd like to generate a C header file like this:
typedef struct {
real_T a;
real_T a1;
} Bus1;
I don't know which tool can help me do this easily, because I don't want to create a real Simulink project and generate entire source code includes *.c and *.h.
So any idea is appreciated!
답변 (1개)
Pierre Debout
2021년 7월 8일
0 개 추천
Hi jiang pengfei,
could you please share your own BBC micro:bit hardware support package for the un-released v2.0 hardware ?
It would help me a lot !
카테고리
도움말 센터 및 File Exchange에서 Create Report Programs Using the Report API에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!