Bus selector cannot find signals where the name has been changed programmatically?

10 次查看(过去 30 天)
Hi, I programmatically need to change signal names in simulink. I use a code similar to:
lineH = find_system(gcs, 'FindAll', 'on', 'type', 'line');
set(lineH, 'Name', 'NewName');
So far so good, but when the changed signal is fed into a bus and should then be selected with a bus selector block, the selector block does not find the "NewName".
I would need to manually open the bus selector block and select the "NewName". Problem is, that there are hundrets of signals to be changed and even much more bus selectors, where the change needs then to be done manually.
Interresting is, that if a signal name change in Simulink is done manually, the bus selectors are somehow updated and the "NewName" is detected automatically without the need of selecting the signal in the respective bus selectors.
Has anyone a solution for this problem? It would be nice, if there was a built in matlab/simulink function that can automatically update all bus selectors after a programmatically performed signal name change?
Thanks for you help. Thomas
  2 个评论
Joe Rustan
Joe Rustan 2022-10-25
I'm facing the exact same problem in Matlab 2019, 2020 and 2021. I can type in a new signal label name and the Bus Selector immediately updates the name at the outport. However, if I try doing it programmatically, this update does not happen and I have to manual remove and re-assign the new name in the Bus Selector.
Any help would be appreciated, thanks.
Prabhakar

请先登录,再进行评论。

回答(1 个)

Shubham
Shubham 2024-8-24
Hey Thomas,
The bus selector block is not able to find the signals whose names have been changed programmatically because the Bus Selector Block treats the input signals as a read only object.
I have attached a very simple model and I was trying to reproduce the issue. I found that I was unable to change the signal label programmatically in the case of Bus selector block. I had tried the code snippet provided by you and I have recieved the following error message: "Cannot change the signal label of a line connecting a Bus Selector."
Alternatively I have tried setting the parameter values of the Bus Selector Block by referring to the following MATLAB Answer:
I have used the following code snippet:
bus_selector_info = find_system(bdroot, 'BlockType','BusSelector');
set_param(bus_selector_info{1}, 'InputSignals','t');
But this has resulted in a different error message: "BusSelector block parameter 'InputSignals' is read-only."
Since the 'Input Signals' parameter is read only, we cannot modify the signal name programmatically. The modification needs to be done manually in this case.
I hope this helps!

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by