Hi anyone explain me about GENERATE and GENERATE_TYPE Functions in tlc file?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello Matlab users,
Anyone pls explain me about GENERATE and GENERATE_TYPE Functions in tlc file writing?
GENERATE_TYPE(block, "Output", "dp_read")
In this structure (Output = "Function name which we want to call", What about block, dp_read. Am using Level 2 M file S Function am not getting any information related to this.
Please help me in resolving this issue.
Thanks in Advance....
回答 (1 件)
Valmir Sadiku
2013 年 5 月 23 日
here you can show example how to use GENERATE : http://www.weizmann.ac.il/matlab/toolbox/rtw/tlc_ref/cp_lan17.html
3 件のコメント
Valmir Sadiku
2013 年 5 月 24 日
編集済み: Valmir Sadiku
2013 年 5 月 24 日
are you able to get the following example to work? if not, tell which error you get?
•The following listing is polymorph.tlc.
%%polymorph.tlc
%language "C"
%%create records used as scopes within the dispatched functions
%createrecord MyRecord { Type "MyBlock"; data 123 }
%createrecord YourRecord { Type "YourBlock"; theStuff 666 }
%%dispatch the functions thru the GENERATE call.
%%dispatch to MyBlock implementation
%<GENERATE(MyRecord, "aFunc")>
%%dispatch to YourBlock implementation
%<GENERATE(YourRecord, "aFunc")>
%%end of polymorph.tlc
•The following listing is MyBlock.tlc.
%%MyBlock.tlc
%implements "MyBlock" "C"
%%aFunc is invoked thru a GENERATE call in polymorph.tlc.
%%MyRecord is in generate scope in this function.
%%Therefore, fields of MyRecord can be referenced without
%%qualification
%function aFunc(r) Output
%selectfile STDOUT
The value of MyRecord.data is: %<data>
%closefile STDOUT
%endfunction
%%end of MyBlock.tlc
•The following listing is YourBlock.tlc.
%%YourBlock.tlc
%implements "YourBlock" "C"
%%aFunc is invoked thru a GENERATE call in polymorph.tlc.
%%YourRecord is in generate scope in this function.
%%Therefore, fields of YourRecord can be referenced without
%%qualification
%function aFunc(r) Output
%selectfile STDOUT
The value of YourRecord.theStuff is: %<theStuff>
%closefile STDOUT
%endfunction
%%end of YourBlock.tlc
The invocation and output of polymorph.tlc, as displayed on the MATLAB console, are shown below:
tlc -v polymorph.tlc
The value of MyRecord.data is: 123
The value of YourRecord.theStuff is: 666
We use in this case STDOUT file to print values to the matlab window.
Which error you got?
Valmir Sadiku
2013 年 6 月 4 日
Please mark this question as answered or close it, if you don't need further support.
参考
カテゴリ
Help Center および File Exchange で Target Language Compiler についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!