Simulink, "Matlab function block" with constant input and dynamic output

조회 수: 4 (최근 30일)
Tom Bernand
Tom Bernand 2019년 8월 28일
편집: Tom Bernand 2019년 8월 28일
Hello,
I want to create a function block with constant inputs, but which has a dynamic output.
Specifically, my input gives me the start value for a function in the block. I want to output the calculated intermediate values (while - loop) in order to use them in another block.
Is this generally feasible with Simulink and if so, how?
Thank you and greetings
Tobias

답변 (1개)

Walter Roberson
Walter Roberson 2019년 8월 28일
No, it does not make sense in Simulink.
What you can do is use a discrete time system. Use a MATLAB Function Block. The state information will tell you when you are initializing; read the inputs and store whatever necessary information into persistent variables. Then after that, each time the function is invoked, refer to the state information you saved in persistent variables and calculate one round of while loop, with the output being the results of the intermediate calculation.
  댓글 수: 1
Tom Bernand
Tom Bernand 2019년 8월 28일
편집: Tom Bernand 2019년 8월 28일
Thank you very much for the quick answer.
The idea with the persistent variables is very good.
However, I don't know exactly how to replace the while loop.
I would now proceed according to the following scheme. First call the function block. Calculate the values, then cache them and finally pass them on. In the next block they are then processed and introduced back into the first block. I would end the loop over a (for or while condition in the first block): Could this work?

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

카테고리

Help CenterFile Exchange에서 Interactive Model Editing에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by