How to programmaticaly set storage class (2020a) in Data Store Memory ?

조회 수: 7 (최근 30일)
Jean Matthieu
Jean Matthieu 2021년 8월 3일
댓글: Fangjun Jiang 2021년 8월 3일
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 ?

답변 (1개)

Fangjun Jiang
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
Jean Matthieu
Jean Matthieu 2021년 8월 3일
That's exactly what i do, but as the question's decriptor says, it doesn't work. It specificaly does not work with 'StateSignalObject' because of the errors mentionned in the description.
Fangjun Jiang
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 CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by