Level 2 Matlab S-function gives error while code generation

7 visualizzazioni (ultimi 30 giorni)
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)

Risposte (1)

Kaustubha Govind
Kaustubha Govind il 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.

Categorie

Scopri di più su Simulink Coder in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by