Level 2 Matlab S-function gives error while code generation
14 views (last 30 days)
Show older comments
I am trying to use a Level 2 Matlab S-funtcion with the below code. There is no problem when I use it in normal mode but when I try to use it in external mode and build the code it says
"The corresponding 'CursOut.tlc' file for the MATLAB S-function 'CursOut' in block 'JustOut/Level-2 MATLAB S-Function' must be located in the current working directory, the MATLAB S-function directory 'C:\Users\generic\Desktop\RT\JustOut', or the directory 'C:\Users\generic\Desktop\RT\JustOut\tlc_c'"
My code is as below. Can anyone help? Thank you.
function CursOut(block)
setup(block);
function setup(block)
block.NumInputPorts = 0;
block.NumOutputPorts = 1;
block.SetPreCompOutPortInfoToDynamic;
block.OutputPort(1).Dimensions = 1;
block.OutputPort(1).DatatypeID = 0;
block.OutputPort(1).Complexity = 'Real';
block.OutputPort(1).SamplingMode = 'sample';
block.NumDialogPrms = 1;
block.RegBlockMethod('Outputs', @Outputs);
block.RegBlockMethod('Terminate', @Terminate);
function Outputs(block)
coords = get(0,'PointerLocation');
block.OutputPort(1).Data = coords(1);
function Terminate(block)
0 Comments
Answers (1)
Kaustubha Govind
on 25 Mar 2014
Simulink cannot generate code from a MATLAB S-function unless you write a TLC file to inline it. See Inline MATLAB File S-Functions.
0 Comments
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!