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?
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Composite Interfaces에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!