RTW s function for different behavior

조회 수: 1 (최근 30일)
Ajit
Ajit 2013년 6월 24일
I need to create a simulink block that will behave differently depending on whether I am simulating the model or building code. If I am simulating the model I want the block to pass the input to the output. If I build the code I want the block to take the text from the mask parameters and add a line to the code saying the output is equal to that string content. Any help will be appreciated.
  댓글 수: 2
Kaustubha Govind
Kaustubha Govind 2013년 6월 24일
Simulink does not support strings as the type of a signal, so I don't think you can have a block output a string. Also, are you open to writing an S-function?
Ajit
Ajit 2013년 6월 24일
Yes. I am open to using an S function. Please see my other comment on the details of what I want to do.

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

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2013년 6월 24일
To get the alternative behavior, you can write a MATLAB/C S-function with a TLC file. The MATLAB/C code defines the simulation behavior, whereas the TLC defines how the block behaves in generated code. You should also be able to obtain such behavior with the MATLAB Function block by using the output of coder.target to figure out whether the block is simulating or generating code.
  댓글 수: 1
Ajit
Ajit 2013년 6월 24일
What I trying to do is as follows:
I am trying to use matlab for autocode generation. For this I have a part of my embedded code implemented in matlab. I have a simulation to run this subsystem and confirm behavior and then I build it to get the actual code I will integrate. What I want is that the inputs to this subsystem need to come from different sources in the model but in the embedded code they need to come from variables. So I need some way to pass through the inputs from the input ports in simulations but change those to a specific variable name (input at the mask) in real time code. I am open to an S function.

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

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by