Is there any way to disable code generation in Simulink

조회 수: 75 (최근 30일)
Adam
Adam 2013년 5월 6일
댓글: Rafael Cordero 2020년 10월 17일
Hi,
I have my own matlab function which I have entered into Simulink as MATLAB Function Block. I use design.lowerpass filter in it as well as other functions that Simulink Coder does not support. I don't want to generate C code for my Simulink model I just want to perform simulations and want Matlab to interpret my function. Is there any way to tell Simulink not to generate code? There seem to be no option to have no target is Simulink. What will happen if I remove Simulink Coder from my path? All the help files are full of how to generate code but none tell how not to generate it.
Regards
Adam

채택된 답변

Guy Rouleau
Guy Rouleau 2013년 5월 6일
Wrap your whole script in a separate MATLAB-file and make it extrinsic so that your MATLAB Function code look like:
%%% function y = myEMLblock(u) coder.extrinsic myWrapper
y = mywrapper(u); %%%
Then put any code you want inside the your wrapper function mywrapper.m
  댓글 수: 5
Miles Walker
Miles Walker 2020년 3월 3일
Thanks for sharing!
Rafael Cordero
Rafael Cordero 2020년 10월 17일
I'm not sure I undestand this answer.
So, the idea is to take the Matlab Function block (or is it the interpreted Matlab function block?) and in that block write:
%%% function y = myEMLblock(u) coder.extrinsic myWrapper
y = mywrapper(u); %%%
Then, inside the mywrapper() function is where I put my code I actually want to run (without C code-generation).
Is that correct? Wont the %%% comment out the first line and make it useless? If I try this with the Matlab Function block, as soon as I save the block code, it inserts the generic y = function u in the first line.

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

추가 답변 (2개)

Gijs van Oort
Gijs van Oort 2013년 5월 6일
Have a look at the coder.extrinsic function within you %codegen'ereated function.. Otherwise, you could try to use the 'interpreted matlab function' and call your self-written m-file which does what you want. (note that the terminology on these user-defined functions has changed somewhere between Matlab2010 and 2012, so have a wide look around in the User-defined functions if you cannot find the adequately named block.
  댓글 수: 1
Adam
Adam 2013년 5월 6일
Hi Gijs,
I have following call in my matlab function. d = fdesign.lowpass('N,Fc', filtOrder, 20.0E+6, ADCclk); Hd = design(d); If I put, before these two lines, coder.extrinsic('fdesign.lowpass'); coder reports: The 'fdesign' class does not support code generation.
Function 'MATLAB Function' (#24.593.600), line 17, column 9: "fdesign" Launch diagnostic report.
Then when I add: coder.extrinsic('fdesign');
The error is the same i.e.: The 'fdesign' class does not support code generation.
Function 'MATLAB Function' (#24.592.599), line 17, column 9: "fdesign" Launch diagnostic report.
The only thing that seems to work is to use feval on those functions. Yes I am aware of the 'interpreted matlab function' and change of the meaning of generic Matlab function block in Simulink.
The question remains though How one can tell Simulink not to bother generating code globally. Some people apart of running their program in Matlab would like to create Simulink diagram by incorporating various matlab written modules just to show overall design of their program with modules interconnections. Just to present their program overall design to outsiders.
Cheers
Adam

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


Shashank Prasanna
Shashank Prasanna 2013년 5월 6일
  댓글 수: 1
Adam
Adam 2013년 5월 6일
Hi Shashank,
yes I was considering it as the name says it all so to speak. But my matlab function outputs two vectors of doubles and interpreted matlab function block can have only one output. This will mean that I have to package my two vectors is 2xN matrix I suppose. I can't believe, which is sort of irrelevant, that one can not tell Simulink not to use Coder unless there is a fundamental reason why this can not be done.
Thanks a lot!

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

카테고리

Help CenterFile Exchange에서 Filter Design에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by