how to add singal and its attributes( data type, min, max values to data dictionary programatically?

조회 수: 16 (최근 30일)
Hello Team,
I have a model with all ojects like IO ports, constants, DSM having their attributes assigned. i.e eachof them have been assigned their dataatype initial value ( if any) min max values, names of each signal/ paramters/DSM is alreayd present in model.
what I need to do is read these all attributes from model and write in sldd. I want to create .m file from this sldd later.
I checked the help , but I could find only 'add Entry' command which allows me to add signal name and its value , parameter name and its type as Simulink. Parameter... but I am not finding anyway to add other attributes to these model objects as mentioned above e.g. my signal is say 'test' i am able to add its name and alue '3 ' throgugh command , but i am not able to add datatype, min max value , same is for parameter, I am abel to add it as a parameter in DD but I am not able to add its datataype, min max values, in DD through script or command prompt.
can someone please suggest me is there any way to do this?
BR
Sameer

채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 7월 1일
What you can do is to create the Simulink.Parameter as a temparary object and assign all its properties and then addEntry().
A more severe shortcoming is when the Simulink.Parameter object already exists in the SLDD and you want to modify its properties.
I had this service request with the Mathworks tech support in Feb. 2019 regarding R2018b. Checking the R2020a document online, there is still no improvement.
% The request
In the attached Test.sldd file created in R2018b, there is a Simulink.Parameter object named "Param". I want to change its data type to "single" through API.
Following standard API, I found it difficult to access the properties of the Simulink.Parameter object.
hSLDD=Simulink.data.dictionary.open('Test.sldd');
hDataSect=hSLDD.getSection('Design Data');
hEntry=hDataSect.getEntry('Param');
While getValue(hEntry) returns a copy of the parameter object,
setValue(hEntry,'DataType','single') (my imaginary syntax) is invalid
To use setValue(), I have to make a copy first.
temp=getValue(hEntry);
set(temp,'DataType','int32');
setValue(hEntry,temp)
I know I can also use evalin(hDataSect,'Param.DataType=''single'';'). But that seems not ideal if I want to change several properties of an abject and I have hundreds of objects.
Anyway, I want to ask if there is a direct API method to get and set the properties of Simulink.Parameter or Simulink.Signal objects in a SLDD. Thanks!
% the reply
I understand that you would like to have a API method to change a Simulink.Parameter object's data type to "single".
There is currently not a direct API way to modify entries in SLDD. The best way would be to create a temp variable as mentioned in your description.
I apologize for the inconvenience this causes you and I will report this to our developers to hopefully have this functionality implemented in future releases.
  댓글 수: 1
Sameer V Kumthekar
Sameer V Kumthekar 2020년 7월 2일
Hello Fangjun,
Thanks for quick reply. I will try using given solution. IN case of any queries I will get back to you.
BR
Sameer

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by