How to programmatically find the Simulink saved version for a .sldd dictionary object
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am now creating a MATLAB script to read the release versions in which a .sldd object is created in Simulink/MATLAB.
What I found but not for .sldd objects:
For example, An SLX file activeSuspension.slx's matlab version it has been saved in can be retrieved using Simulink.MDLInfo object and it's property 'ReleaseName'.
mdlInfo= Simulink.MDLInfo('activeSuspension');
matlabVersion=mdlInfo.ReleaseName;
From documentation https://in.mathworks.com/help/simulink/slref/simulink.mdlinfo.html I am aware that MDLInfo is only limited to .slx,.slxp and .mdl files.
My Query:
Now coming to my query, I would like to know if there is any direct API command like MDLInfo or a resuable script available to get the matlab version created for a .sldd file.

Since the metadata is visible in MATLAB UI for a .sldd file I believe there is a solid possibility to have an API command from which the "Saved in Simulink " version can be found, but I am unlucky so far to find one from documentation. Thanks in advance.
0 Kommentare
Antworten (1)
Anay
am 31 Jan. 2025
Hi Akhil,
I did not find any inbuilt functionality to get the MATLAB release version from the “Simulink Data Dictionary” files in the MATLAB documentation. There is a way to programmatically find the version of MATLAB/Simulink which created your “.sldd” file. I found that the “.sldd” files are stored as a compressed archive, similar to a “.zip” file. When you “unzip” a “.sldd” file you find a bunch of files which are used to store data and metadata of that object. In these files, there is a file named “mwcoreProperties.xml” which has the version of MATLAB used to create that file under the tag “matlabRelease”. So, in a nutshell, follow these steps to programmatically get release version from a “.sldd” file:
1. Unzip the “.sldd” file
2. From the extracted data, read the “mwcoreProperties.xml” file
3. Get the MATLAB version from the tag “matlabRelease”
Here is a sample code you can use for reference:
dictFilePath = 'dummyDictionary.sldd';%Change this to the path to your .sldd file
opFldr = 'sldd_temp';%Output folder path to extract the contents of the .sldd file
if ~exist(opFldr, 'dir')%Check if output folder exists
mkdir(opFldr);%If not, create the folder
end
unzip(dictFilePath, opFldr);%Extract contents of the .sldd file
releaseMetaData = fullfile(opFldr, 'metadata', 'mwcoreProperties.xml');%Path of the mwcoreProperties.xml file
xmlDoc = xmlread(releaseMetaData);% Read the mwcoreProperties.xml file
rootNode = xmlDoc.getDocumentElement();% Get the root element of mwcoreProperties.xml
matlabReleaseNode = rootNode.getElementsByTagName('matlabRelease').item(0);%Find the matlabRelease tag in mwcoreProperties.xml
if ~isempty(matlabReleaseNode)%check if the element exists
matlabRelease = char(matlabReleaseNode.getTextContent());%if yes, get the content (MATLAB version name)
fprintf('MATLAB Release: %s\n', matlabRelease);
else
disp('matlabRelease tag not found.');
end
%Delete the temporary folder after inspection
rmdir(opFldr, 's');
Hope this helps.
Siehe auch
Kategorien
Mehr zu Desktop finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!