Is it possible to make input or output ports in Simulink to automatically take the name of the signal?

17 visualizzazioni (ultimi 30 giorni)
Is it possible to make input or output ports in Simulink to automatically take the name of the signal?
So for example, I have a signal name of "test_input". Is there a way for Matlab to retrieve the signal name? I guess to set the port name we can just use set_param.

Risposta accettata

TAB
TAB il 3 Lug 2012
There is a ConnectionCallback function which can be implemented for the port of the blocks. This callback is triggered every time connectivity to the port is changes.
Implement this callback for your input and output ports. Inside the callback, you can write the code to get the signal name to which port is connected using get_param() and set the port name using set_param().

Più risposte (1)

Horace
Horace il 3 Lug 2012
How do I set the port name using set_param?
Apparently set_param(port_handle, 'Name', 'test_name') doesn't work
"Invalid setting in port '' for parameter 'Name'"
  1 Commento
TAB
TAB il 3 Lug 2012
Modificato: TAB il 3 Lug 2012
What is port_handle ?
Is it handle to the Inport/Outport block or it is handle to Port of the block ?
To change the Inport/Outport block name you need handle to the block.

Accedi per commentare.

Categorie

Scopri di più su Programmatic Model Editing in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by