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

조회 수: 10 (최근 30일)
ThomasMatlab
ThomasMatlab 2016년 10월 11일
답변: Gojo 2024년 8월 24일
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
Ravindra Goyal
Ravindra Goyal 2024년 8월 22일
I am also wondering, as I have also the exact same problem (Matlab 2022b)...!

댓글을 달려면 로그인하십시오.

답변 (1개)

Gojo
Gojo 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