matlab function call class in workspace
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello,
First, I define a classdef named "ModelClass" with various properties, methods and functions.
Then I set global A = ModelClass and assign various values to properties of A.
A is now a global "1x1 ModelClass" value and saved in matlab workspace.
Now I'm trying to use A in Matlab Function in Simulink. Is it possible?
If yes, how can I do this.
Btw, I also have to generate S function of this Matlab Function. Therefore, I cannot use Interpreted Matlab Function.
댓글 수: 0
답변 (1개)
Swastik Sarkar
2025년 6월 23일
편집: Swastik Sarkar
2025년 6월 23일
In MATLAB Level-2 S-functions, the recommended method for maintaining persistent data across simulation steps is through the use of DWork vectors. These vectors are designed to store numeric or logical values. However, it is important to note that MATLAB class objects are not supported within DWork vectors. This limitation is documented in the official MathWorks Documentation:
As an alternative, the UserData property of a Simulink block may be used to store an instance of a MATLAB class. This property allows arbitrary MATLAB data, including class objects, to be associated with a block.
An example demonstrating this technique is available on MATLAB Central:
Further information on the UserData property can be found in the MATLAB documentation:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!