How to programmaticaly set storage class (2020a) in Data Store Memory ?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Fangjun Jiang
el 3 de Ag. de 2021
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 comentarios
Fangjun Jiang
el 3 de Ag. de 2021
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.
Ver también
Categorías
Más información sobre Sources en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!