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!