필터 지우기
필터 지우기

Sharing variables inside Level-2 MATLAB S-function

조회 수: 4 (최근 30일)
Nicolò Badodi
Nicolò Badodi 2019년 4월 9일
답변: Peter Koch 2019년 7월 19일
Hi, I have a conceptual question:
I'm creating a simulink block using a Level-2 MATLAB S-function, I need the Start function to create an object (variable1 for example), which must keep existing until the Terminate function clears it.
This variable1 object must be accessed from all the other functions called by the block, like the Output function that calculates the value of the output port of my block (I only have one), so my solution was to declare this variable1 object as global.
Is there any way to make the object exist only inside the workspace of the block I am creating, and be shared only between the registered functions of the level-2 MATLAB S-function, so I can avoid to make it global?
Thanks in advance for the answers!
  댓글 수: 1
Mario Seiler
Mario Seiler 2019년 7월 1일
Hi did you or anybody else already find a solution to this problem?

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

채택된 답변

Peter Koch
Peter Koch 2019년 7월 19일
Hi,
I´m not sure if this is what you meant, but using a DWork vector should solve your problem.
Like stated in the link below, the DWork vector stores the discrete information of your variable through all functions in your
S-Function.
Regards.

추가 답변 (0개)

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by