Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get location of signal name on signal line (MATLAB/Simulink)

I have some problems about signal name when I set a name to signal.

Now I can set and get signal name by

set_param(signal_h, 'SignalNameFromLabel', signal_name);

and

get_param(signal_h, 'Name');

But I can not set or get location of signal name.

I opened .mdl as text (notepad++) then I found *.mdl keep location of signal name as matrix in Labels parameter

So I would like to ask you all, How can I set or get location of signal name by command line.

Sorry for my English skill. Thank you for all answers.

enter image description here

like image 291
Kritsada Tattanon Avatar asked Oct 20 '22 21:10

Kritsada Tattanon


2 Answers

When you inspect your signal handle, you won't find any property changing, when you modify the signal position. So I would assume there is no simple way to do what you want. Maybe you can work with the underlying java objects, but it will complicated. (... and I can't help on that)

I assume you create your whole model programmatically, don't you? So you specify the exact position of your blocks and probably use the add_line command to draw the connections. Why not considering labeling the signals using annotations? You name your signal as before, but you don't make the label visible. Instead of this you use a programmatically generated annotation, like in the example of the documentation linked above:

new_system('test')
open_system('test')
add_block('built-in/Gain', 'test/Gain', 'Position', ...
[260, 125, 290, 155])
add_block('built-in/Note','test/programmatically created', ...
'Position', [550 0 0 180])

enter image description here

like image 137
Robert Seifert Avatar answered Nov 01 '22 09:11

Robert Seifert


As thewaywewalk mentioned, there's no programmatic way of doing what you want (at least none that is documented). You can programmatically name a signal by setting the name parameter of the port or line that represents the signal:

p = get_param(gcb, 'PortHandles')
l = get_param(p.Outport, 'Line')
set_param(l, 'Name', 's9')

But according to the documentation, you can only move the signal label interactively with the mouse:

Move Signal Labels

Labels can appear above or below horizontal lines or line segments, and left or right of vertical lines or line segments. Labels can appear at either end, at the center, or in any combination of these locations.

To move a signal label, drag the label to a new location on the line. When you release the mouse button, the label fixes its position near the line. You cannot drag a label away from its signal, but only to a different location adjacent to the signal.

like image 35
am304 Avatar answered Nov 01 '22 10:11

am304