Matrix representation in generated C code / asap2 file

5 ビュー (過去 30 日間)
Thomas Becker
Thomas Becker 2015 年 6 月 17 日
コメント済み: Thomas Becker 2015 年 6 月 18 日
Hi there,
when I generate code from a Simulink model with calibratable vector and matrix parameters, both parameters are generated as 1-dimensional arrays in C code.
Initialization m-file
ADS_InitValue_1x1 = Simulink.Parameter(zeros(1,1));
ADS_InitValue_1x12 = Simulink.Parameter(zeros(1,12));
ADS_InitValue_5x11 = Simulink.Parameter(zeros(5,11));
a2l file (reduced)
/begin CHARACTERISTIC
/* Name */ ADS_InitValue_1x1
/* Type */ VALUE
/end CHARACTERISTIC
/begin CHARACTERISTIC
/* Name */ ADS_InitValue_1x12
/* Type */ VAL_BLK
/* Array Size */
NUMBER 12
/end CHARACTERISTIC
/begin CHARACTERISTIC
/* Name */ ADS_InitValue_5x11
/* Type */ VAL_BLK
/* Array Size */
NUMBER 55
/end CHARACTERISTIC
Unfortunately, with this result it's not possible to distinguish between vector and matrix parameters later in the calibration system.
Is there any possibility to change that behaviour? Or to distinguish between vector/matrix when parsing the a2l file?
Thanks in advance, Thomas

採用された回答

Andrew Schenk
Andrew Schenk 2015 年 6 月 18 日
All Simulink signals and parameters will be code generated as 1-D vectors. If all your variable names are consistent with the format you have shown above, you can parse the Name characteristic to extract the NxM portion. If N > 1, the parameter is a matrix.
Another possibility would be to modify the TLC used to generate the a2l file as described in the following documentation: http://www.mathworks.com/help/rtw/ug/customizing-an-asap2-file.html
You would need to modify the asap2scalar.tlc file to include an additional characteristic or comment with the MATLAB parameter dimension.
  1 件のコメント
Thomas Becker
Thomas Becker 2015 年 6 月 18 日
Andrew, thanks very much! Not what I had hoped to read, but at least a possibility to go on. Looking forward to TLC scripting :-)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by