MATLAB Answers


How to save a buffer from a tlc file and use it in another tlc file

Asked by Babak
on 30 Nov 2012
Latest activity Answered by Zhai Diego
on 1 May 2014

In writing TLC files, I want to open a buffer and write stuff there and close it and use the buffer at another TLC file which will be used later in the code generation process.

Here's what I did already:

 %openfile OutputBlocksBuffer
 things I want to write here...
 %closefile OutputBlocksBuffer
 %<SLibCacheCodeToFile("OutputBLK.txt", OutputBlocksBuffer)>

But it doesn't recognize "OutputBLK.txt". It doesn't necessarily have to be a .txt file but could be any buffer as long as a second TLC file can find the buffer and have access to its contents. There is no documentation that I could find on %<SLibCacheCodeToFile(.,.)> but it is widely used in ERT system target files.


2 Answers

Answer by Kaustubha Govind
on 30 Nov 2012
 Accepted answer

Since SLibCacheCodeToFile is not documented, I'm not sure what the write way to use it is. Typically the documented functions used to write TLC strings write to source files (eg. LibCreateSourceFile). If you are unable to find any other solution, I would recommend creating your own MATLAB function that uses File I/O functions like fopen, etc. to read/write to files and invoke that from TLC using FEVAL.

For example:

   FEVAL("myhelper", OutputBlocksBuffer)


Answer by Zhai Diego
on 1 May 2014

An alternative approach is that you can attach your "things" to ::CompiledModel Record,the function *%<LibAddToCompiledModel(name, value)>*


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!