Accessing Signal in MATLAB SLDD from bus editor

8 次查看(过去 30 天)
I have a sldd which contains various simulink busses inside it, I wanted to access the signals which were present inside the busses so as to write a excel file from it.
Is there any way to do this?

回答(1 个)

Vignesh
Vignesh 2023-10-11
Hello Harsh Mittal,
I see that you are looking for a way to access the signals that are present inside a bus which are there in the Simulink Data Dictionary.
I found a similar question in the community where the usage of ‘arrayfun’ and ‘cellfun’ functions were suggested to edit the bus elements pragmatically and I suggest you refer the same. Please use the following question to view the question.
Kindly refer to the following example code with key parts key parts to accessing the element names, please modify this code to meet your requirements.
sldd_object = Simulink.data.dictionary.open('filename.sldd');
section = getSection(sldd_object, 'Design Data');
entries = find(section, '-value', '-class', 'Simulink.Bus');
% produce cell array of Simulink.Bus objects:
buses = arrayfun(@(x) getValue(x), entries, 'UniformOutput', false);
% produce a cell array of cell arrays of Simulink.BusElement objects:
elements = cellfun(@(x) x.Elements, buses, 'UniformOutput', false);
% produce a cell array of cell arrays of element names:
element_names = getElementNames(elements);
function names = getElementNames(arrayOfElements)
%%getElementNames returns a cell array of element names
function names = busElementNames(busElement)
if (length(busElement)<1)
errordlg('There is a bus with zero elements. Oops.')
elseif (length(busElement)==1)
names{1}{1} = busElement.Name;
else
names = arrayfun(@(x) x.Name, busElement, 'UniformOutput', false);
end
end
names = cellfun(@busElementNames, arrayOfElements, 'UniformOutput', false);
end
I hope this helps you in accessing the bus elements from SLDD.

类别

Help CenterFile Exchange 中查找有关 Composite Interfaces 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by