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

16 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 1 Juil 2020
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 commentaire
Sameer V Kumthekar
Sameer V Kumthekar le 2 Juil 2020
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

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by