f562
f562

Reputation: 21

Access signal name in Simulink directly

Is there a way to access a signal's name in Simulink and then, for example, write it into a constant block?

I know there is the get_param command for MATLAB, but this is not what I am looking for.

Upvotes: 1

Views: 2875

Answers (2)

Nathol
Nathol

Reputation: 29

It is also possible to write the signal to the Matlab workspace with the "To Workspace" block. You could then again access it by using assignin. See http://de.mathworks.com/help/matlab/ref/assignin.html

Don't forget to use set_param(bdroot,'SimulationCommand','update') to update your simulation with the new value, see http://de.mathworks.com/help/simulink/ug/using-the-set-param-command.html

Upvotes: 0

am304
am304

Reputation: 13886

I think you have to go via get_param using the block from which the signal originates, e.g.:

p = get_param(gcb, 'PortHandles');
l = get_param(p.Outport, 'Line');
sig_name = get_param(l, 'Name');

See Signal Names and Labels in the Simulink documentation.

Upvotes: 2

Related Questions