MATLAB Answers

Code generation for Level 2 M-S Function

4 views (last 30 days)
Vivek
Vivek on 22 May 2014
Edited: Vivek on 22 May 2014
I am using a level 2 matlab s function in my model. When I try to generate code, got a error "tlc not found".
Don't know to write a tlc file, hence its an urgent requirement.
Can any one give me a c or tlc file which performs the inbuilt Simulink lookup table functionality.
Generally lookup table doesn't support for enumeration datatype. So only this function is created. If any one has this already, please give it to me.
My mask subsystem is
Here both of my inputs are enum type. My S fcn code is
function Test1(block)
%#eml
%model_call A Template for a Level-2 MATLAB S-Function
setup(block);
end
function Outputs(block)
xVal =double(block.InputPort(1).Data);
yVal =double(block.InputPort(2).Data);
xRow=double(block.DialogPrm(1).Data);
yCol=double(block.DialogPrm(2).Data);
zTbl=double(block.DialogPrm(3).Data);
LkMthd=block.DialogPrm(4).Data;
if yVal>yCol(end)
yVal=yCol(end);
elseif yVal<yCol(1)
yVal=yCol(1);
end
if xVal>xRow(end)
xVal=xRow(end);
elseif xVal<xRow(1)
xVal=xRow(1);
end
block.OutputPort(1).Data=interp2(xRow,yCol,zTbl,yVal,xVal,LkMthd);
end --the shown above is the only change from the Level 2 MS Function template.

  0 Comments

Sign in to comment.

Answers (0)

Sign in to answer this question.