writing tlc file for level 2 m file s function which accessing guidata

조회 수: 3 (최근 30일)
sai vasavi
sai vasavi 2013년 4월 26일
댓글: Hari Rangarajan 2021년 12월 17일
Hello Matlab users, I have written m file s function which takes checkbox selection input and this input signal enables simulink subsystem.When I am trying to generating C code from this model by using RTW it is looking for corresponding tlc file in the current working directory.Please Can anyone share the procedure to write tlc file .the outputs function in sfunction looks like
function outputs
persistent h
if isempty(h)
h = guidata(my_gui);
end
block.OutputPort(1).Data = get(h.MOTOR_auto_reset,'Value');
%endfunction
  댓글 수: 6
Kaustubha Govind
Kaustubha Govind 2013년 5월 7일
Please use the TLC Debugger to see what value is returned to out.
vinothkannan K
vinothkannan K 2013년 5월 10일
편집: vinothkannan K 2013년 5월 10일
yeah Kaustubha Govind, we are from same team. Is there any standard format available to write tlc? Any structure for tlc file we wrote like this
%implements "IFM_Select" "C"
%function Outputs(block, system) Output
%assign y = LibBlockOutputSignal(0,"","",0)
%assign out=FEVAL("IFM_Select_fcn")
%<y>=%<out>
%endfunction%%[EOF] IFM_Select.tlc
Please help us in resolving this issue.

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

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2013년 5월 10일
Yes, your TLC code looks right to me, except that you need to add a semicolon to the end of the line "%<y>=%<out>" as required by all C statements:
%implements "IFM_Select" "C"
%function Outputs(block, system) Output
%assign y = LibBlockOutputSignal(0,"","",0)
%assign out=FEVAL("IFM_Select_fcn")
%<y>=%<out>;
%endfunction
%%[EOF] IFM_Select.tlc
Also, note that you appear to be making the assumption that the MATLAB function IFM_Select_fcn returns a scalar value of the same datatype as what the S-function's output port is configured for, so please make sure that is true.
  댓글 수: 2
Wenjie Shi
Wenjie Shi 2016년 10월 19일
Thanks for your answer, it's easy to be ignored but useful.
Hari Rangarajan
Hari Rangarajan 2021년 12월 17일
Here is some documentation on how to write Level 2-MATLAB S-Functions. The Template section also provides the MATLAB command to open a template TLC file: https://www.mathworks.com/help/simulink/sfg/writing-level-2-matlab-s-functions.html

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

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by