Hi anyone explain me about GENERATE and GENERATE_TYPE Functions in tlc file?

1 回表示 (過去 30 日間)
vinothkannan K
vinothkannan K 2013 年 5 月 23 日
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....
  2 件のコメント
vinothkannan K
vinothkannan K 2013 年 5 月 23 日
Hi, I read that also "The first argument must be a valid scope" what is that first argument?

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

回答 (1 件)

Valmir Sadiku
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
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
Valmir Sadiku 2013 年 6 月 4 日
Please mark this question as answered or close it, if you don't need further support.

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

カテゴリ

Help Center および File ExchangeTarget Language Compiler についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by