How to programmaticaly set storage class (2020a) in Data Store Memory ?
7 次查看(过去 30 天)
显示 更早的评论
Hi, I use Matlab 2020a.
I have hundreds of Data Store Memory Block that i generate on the Simulink model from an external file (Excel).
I've got a custom package ('mypackage') and a custom storage class within this package ('DataStore').
It works when i do it manualy.
What i want to do is setting by command line the package 'mypackage' with my storage class 'DataStore' into my data store memory block. It works when i do it manualy. To do that, i tried:
1) set(DSM_Block, 'StateSignalObject', mypackage.Signal)
--> It gives back:
"Invalid input for argument 1 (rhs1):
Value must be 'matlab.mixin.SetGet'.
Error in Simulink.DataObject/set"
2) a=get(DSM_Block_with_good_package, 'StateSignalObject')
set(DSM_Block, 'StateSignalObject', a)
--> It gives back:
"Invalid input for argument 1 (rhs1):
Value must be 'matlab.mixin.SetGet'.
Error in Simulink.DataObject/set"
And if i only write "set(DSM_Block,'StateStorageClass', 'DataStore');",
--> it gives back
"Invalid setting in DataStoreMemory block 'My_Bus' for parameter 'StateStorageClass'
Caused by:
'DataStore' is not a valid storage class"
Can you please help me ?
0 个评论
回答(1 个)
Fangjun Jiang
2021-8-3
if "DSM_Block" is a block handle, you can use get/set
if "DSM_Block" is a block path, use set_param/get_param
2 个评论
Fangjun Jiang
2021-8-3
I tried it in R2020a. It seemed that way. It might have some dependency but hard to experiment.
I usually do it in a different way. You have hundres of DSM blocks. Each must have a unique data store name (the default is "A", for example). You need to create a signal object in base workspace or data dictionary
A=mpt.Signal and then set whatever property/value pair.
In the block, check "Data store name must resolve to Simulink signal object" option
command line is set_param(BlockPath,'StateMustResolveToSignalObject','On')
This way, the properties that you want to set are all linked to that sigal object.
This is a better way to manage the DSM blocks.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!