How to retrieve the Inport names/labels of a Stateflow chart?

22 ビュー (過去 30 日間)
Max Heimann
Max Heimann 2022 年 1 月 13 日
コメント済み: Max Heimann 2022 年 1 月 18 日
Hello, I am looking for a way to programatically retrieve the portnames of a stateflow chart.
Curiously get_param(gcb,'OutputSignalNames') returns a cell array of strings with the names of all outports of the chart. However get_param(gcb,'InputSignalNames') returns an empty cell. I tried several other parameters, aswell as analyzing the PortHandles of the chart directly, but without success.
Why does 'InputSignalNames' return a blank cell? Are there certain prerequisites for this parameter to work as expected? Are there alternative parameters?
Is there a possible workaround? E.g. is there an API for the model explorer which would allow me to parse the chart data for variables with "Scope" -> "Input"?
Thank you in advance!


Monika Jaskolka
Monika Jaskolka 2022 年 1 月 18 日
I'm not sure what the InputSignalNames parameter is used for and there is little information about it in the Simulink documentation. It was also empty for me.
Alternatively, you can use the Stateflow API to get the information you are looking for. For example:
chartName = 'Security System';
chart = find(sfroot, '-isa', 'Stateflow.Chart', 'Name', chartName);
inport = find(chart, '-isa', 'Stateflow.Data', 'Scope', 'Input');
inport_name = arrayfun(@(x) x.Name, inport, 'UniformOutput', false)
inport_name = 7×1 cell array
{'D_mode' } {'W_mode' } {'M_mode' } {'Door_sens' } {'Win_sens' } {'Mot_sens' } {'Alarm_active'}
  1 件のコメント
Max Heimann
Max Heimann 2022 年 1 月 18 日
The documentation for that parameter is really not great. In my tests OutputSignalNames returned exactly what i was looking for, so i assumed that the InputSignalNames Parameter would work the same.
I tried your alternative solution and it works perfectly for Inports and Outports. Thank you very much!


その他の回答 (0 件)


Find more on Stateflow Programmatic Interface in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by