Effacer les filtres
Effacer les filtres

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

10 vues (au cours des 30 derniers jours)
ThomasMatlab
ThomasMatlab le 11 Oct 2016
Réponse apportée : Shubham le 24 Août 2024
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 commentaires
Joe Rustan
Joe Rustan le 25 Oct 2022
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
Ravindra Goyal
Ravindra Goyal le 22 Août 2024
I am also wondering, as I have also the exact same problem (Matlab 2022b)...!

Connectez-vous pour commenter.

Réponses (1)

Shubham
Shubham le 24 Août 2024
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!

Community Treasure Hunt

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

Start Hunting!

Translated by