About how to generate C header files with MATLAB scripts.
Show older comments
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!
Answers (1)
Pierre Debout
on 8 Jul 2021
0 votes
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 !
Categories
Find more on Create Report Programs Using the Report API in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!