How to initialize a Unit Delay block with a Bus signal from a Data Dictionary in the Model Workspace in R2021a?

4 views (last 30 days)
My model contains a Bus signal feeding a Unit Delay block which should be initialized:
So that Bus elements a and b have different initial conditions.
I saw that one can use the following workflows:
But how can I create the MATLAB struct inside the Model Workspace which should get Bus type data from a Data Dictionary (DD). Besides this I also want to use variables/values from the Base Workspace in the MATLAB struct.
How can I do this?

Accepted Answer

Mathworks支万博1manbetx持团队
The attached example contains the following information which solves the issue:
的符合lowing MATLAB code is used to create the struct:
initBUS = Simulink.Parameter;
myDictionaryObj = Simulink.data.dictionary.open('testDD.sldd');
initBUS.DataType ='Bus: myBus';
initBUS.Value = Simulink.Bus.createMATLABStruct('myBus',[],1,mydictionaryobj);%使用“scope”属性初始化结构,以搜索数据字典中的类型
initBUS.Value.a = evalin('根据','aVar');%gets data from Base Workspace
initBUS.Value.b = evalin('根据','bVar');%gets data from Base Workspace
清除myDictionaryObj
的符合lowing property is used to get the Bus type from the Data Dictionary:
After that you simply only have to add the variable initBUS in the Unit Delay mask as follows:
and finally the simulation result is correctly initialized:
如果有任何不清楚,请考虑联系技术支持团队以获取进一步的帮助。万博1manbetx

More Answers (0)

Tags

No tags entered yet.

s manbetx 845


释放

R2021a

Community Treasure Hunt

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

开始狩猎!

Translated by