Running fcn.m file in a block on simulink

Hi ! I was wondering wether there was anyway to call a function.m file in simulink, having created the file in Matlab, in a simulation ?
I know the use of the Matlab Function block, but in my particular case, I need to declare some symbolic variables ('syms s t') to use in an inverse Laplace transformation that will give me my output signal.
Therefore, the declaration of my symbolic variable is not supported while generating the C code of the Matlab Function block, that's why i can't use it.
Also I'm trying to find a way without using S-Function block in Simulink if possible !
Cheers

 채택된 답변

Sebastian Castro
Sebastian Castro 2014년 11월 20일

0 개 추천

Yael,
If you want this to just run within the MATLAB environment (i.e., you're not generating code from your model), you can do one of two things:
  1. Declare unsupported MATLAB functions as extrinsic using coder.extrinsic. If you scroll down, the documentation link has an example using plotting commands, which are not supported for code generation. You'd have to do to the same for all Symbolic Math Toolbox commands like syms .
  2. If your function inputs and outputs are all of double data type so that you can put them together in a vector, you can also use the Interpreted MATLAB Function block.
The Interpreted MATLAB Function block is probably easier, but I'd recommend using coder.extrinsic if you can.
Best, Sebastian

댓글 수: 1

yael
yael 2014년 11월 21일
편집: yael 2014년 11월 21일
Hi Sebastian
I'll try to use 'coder.extrinsic' command To get my simulation. If I get it correct, it will allow simulink to dispatch the code generation to matlab, hence avoiding C-compilation of the non-supported function, right ?
Thanks for the tip I'll keep you posted if it works !
Edit : The coder.extrinsic works just fine, allowing Simulink to run through the code generation properly.
Thanks a lot again for your quick answer. Some other problems have arisen though, but I'll deal with them later, since it's not linked with the code-generation anymore.
Regards, Yael

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품

질문:

2014년 11월 20일

편집:

2014년 11월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by