how to add singal and its attributes( data type, min, max values to data dictionary programatically?
5 次查看(过去 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
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Results, Reporting, and Test File Management 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!