Target Language Compiler | ![]() ![]() |
Counting Blocks and Subsystems
The Target Language Compiler is a program that transforms model
.rtw
record files and S-functions into C source code. In this exercise you will modify a program that reports the blocks contained in a model
.rtw
file. You can use the TLC utility scripts from this exercise to list the contents of any such .rtw
file, not just the one used in the example.
listrtw1.tlc
in your text editor. As provided, it contains
%% File: listrtw1.tlc %% Count blocks and subsystems of a model.rtw file %% %% %% NOTE: Change "<matlabroot>/" below to the %% MATLAB main directory on your system %addincludepath "<matlabroot>//rtw//c//tlc//lib" %assign Accelerator = 0 %%Needed to avoid error in utillib %include "utillib.tlc" %selectfile STDOUT *** SYSTEMS AND BLOCKS IN RECORDFILE %assign nbls = 0 %with CompiledModel %foreach sysIdx = NumSystems %with System[sysIdx] %assign nbls = nbls + NumBlocks *** %<NumBlocks> blocks in system %<sysIdx + 1> %endwith %endforeach *** recordfile contains %<nbls> blocks in %<NumSystems> systems %endwith *** END LISTING %% end listrtw1.tlc
Note that the following TLC directives are used (refer to Directives and Built-in Functions, for detailed descriptions):
%addincludepath "<matlabroot>//rtw//c//tlc"
and change <matlabroot>
to specify the MATLAB root directory on your system. The double slashes are required to parse the string properly.
listrtw1.tlc
on the f14a.rtw
file. Do this by typing the tlc
command in MATLAB (type help tlc
for command syntax information). In the MATLAB command window (having made sure you are currently in your own /listrtw
directory) type
The model file is read and analyzed by listrtw1.tlc
, which prints the following summary of it in the MATLAB command window:
*** SYSTEMS AND BLOCKS IN RECORDFILE *** 8 blocks in system 1 *** 10 blocks in system 2 *** 4 blocks in system 3 *** 7 blocks in system 4 *** 17 blocks in system 5 *** recordfile contains 46 blocks in 5 systems *** END LISTING
![]() | Getting Started | Listing Block Names | ![]() |