Exchange random variable name between several TLC files

조회 수: 1 (최근 30일)
Macko
Macko 2011년 10월 19일
Hi,
I would like to dynamically generate a random variable name in one of my TLC files and use this in several other TLC files.
How would I go about:
1. Generating a random variable name?
2. Passing the generated variable name to other TLC files?
Many thanks in advance for your time and help!

채택된 답변

Kaustubha Govind
Kaustubha Govind 2011년 10월 19일
1) How do you create the variable? If you are simply generating it using TLC and it is not directly associated with a signal and parameter, you can write a MATLAB function (say it is called generateRandomName) with the code the cyclist suggested and call it from TLC using something like:
%assign varname = FEVAL("generateRandomName")
int %<varname> = 100;
2) It depends on what you mean by passing it on to other TLC files - do the other files consist of functions? Are they called from the code in question? If yes, you can simply pass on the variable as function arguments. You can also consider using the "addtorecord" TLC directive to add this information to an existing record so that all other TLC files can also look at that same record and use the variable name.
  댓글 수: 1
Macko
Macko 2011년 10월 20일
Thank you! This sounds like a fesible way to implement this.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

the cyclist
the cyclist 2011년 10월 19일
I don't know anything about TLC files (or even what they are). But this little algorithm will generate a random file name (of length 10):
alphabet = 'abcdefghijklmnopqrstuvwxyz';
index = randi(26,1,10);
filename = alphabet(index);
  댓글 수: 1
Macko
Macko 2011년 10월 20일
Thank you for the suggestion!
TLC files are used by RTW to generate code from Simulink models.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Code Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by