celestialorb
celestialorb

Reputation: 1979

Programmatically Labeling a Signal in Simulink

I'm attempting to write a script that generates a basic Simulink model and I'd like to know if there's a way to programmatically label a signal line. I've looked at the add_line function (which is what I'm using to add the lines), but I don't see an option for defining anything like a Name or Label property.

Is there a way to do this?

Upvotes: 5

Views: 11426

Answers (2)

TobiasP
TobiasP

Reputation: 61

add_line returns a handle to the newly created line, so you could also write:

lineHandle = add_line('sys','oport','iport');
set_param(lineHandle, 'Name', 'yourSignalName');

Upvotes: 6

anon
anon

Reputation:

Using the currently selected block gcb or the name of the block whose output signal you want to name, you can write

name = gcb
h = get_param(name, 'PortHandles')

h = 
  Inport: [72.0029 73.0029]
 Outport: 74.0029
  Enable: []
 Trigger: []
   State: []
   LConn: []
   RConn: []
Ifaction: []

set(h.Outport(1), 'SignalNameFromLabel', 'output_sig')

Upvotes: 4

Related Questions