How to declare and use local variable in level 2 s-function?

조회 수: 3 (최근 30일)
Ankitkumar Viradiya
Ankitkumar Viradiya 2017년 11월 20일
댓글: Ankitkumar Viradiya 2017년 12월 3일
I have a scenario in which I have to connect to client once and then need to use same connection object for further processing. I am planning to connect client in START function in S-function and in same block I want to declare variable which can be access from OUTPUT block for further processing. So please suggest me some way to achieve this or give some reference example. Thanks....

답변 (1개)

Mark McBroom
Mark McBroom 2017년 11월 26일
You will need to set up a "DWork" variable that gets assigned a value in the mdlStart() function and can then be used in the mdlOutput() function. This link gives details on creating and using a DWork variable in an s-function.
  댓글 수: 1
Ankitkumar Viradiya
Ankitkumar Viradiya 2017년 12월 3일
Thanks for the answer. I have tried these methods already but it is working for just int,double or boolean data types. But I have custom class object and I want to pass this object via Dwork variable. While doing so it throws an error even if I use "inherited" data type. So please guide me how to handle such class object in s-function in matlab file. I am not using c/c++ file to do this. Please guide me on this. Thanks in advance.

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

카테고리

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