フィルターのクリア

Accessing Signal in MATLAB SLDD from bus editor

4 ビュー (過去 30 日間)
Harsh Mittal
Harsh Mittal 2022 年 6 月 29 日
回答済み: Vignesh 2023 年 10 月 11 日
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 Center および File ExchangeEvent Functions についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by