Discussion:
Simulink block position
(too old to reply)
Christophe Boudrie
2007-10-18 13:32:33 UTC
Permalink
Hi,

I have some strange behaviour with simulink when I try to
position some blocks by using command line.

For example:

I try to place a bus selector block,
set_param(mybus_selector,'Position',[140 29400 160 32760]);
(my grid spacing is =20)

and when I check where this block is placed:
real_bus_position=get_param(mybus_selector,'Position');
I get: real_bus_position=[[140 0 160 3400]];
Which is very different from what I asked for.

I want to understand the reason of this difference, I need
to manage automatically this positionning.

Thanks,

CB.
Fangjun Jiang
2007-10-18 14:02:03 UTC
Permalink
There is a limit on the maximum value of those
coordinates. I don't remember though. Try your command
individually at the command line and see what message you
got from Simulink. I remember it tells you the limit value.
Post by Christophe Boudrie
Hi,
I have some strange behaviour with simulink when I try
to
Post by Christophe Boudrie
position some blocks by using command line.
I try to place a bus selector block,
set_param(mybus_selector,'Position',[140 29400 160
32760]);
Post by Christophe Boudrie
(my grid spacing is =20)
real_bus_position=get_param(mybus_selector,'Position');
I get: real_bus_position=[[140 0 160 3400]];
Which is very different from what I asked for.
I want to understand the reason of this difference, I
need
Post by Christophe Boudrie
to manage automatically this positionning.
Thanks,
CB.
Fangjun Jiang
2007-10-18 14:02:03 UTC
Permalink
There is a limit on the maximum value of those
coordinates. I don't remember though. Try your command
individually at the command line and see what message you
got from Simulink. I remember it tells you the limit value.
Post by Christophe Boudrie
Hi,
I have some strange behaviour with simulink when I try
to
Post by Christophe Boudrie
position some blocks by using command line.
I try to place a bus selector block,
set_param(mybus_selector,'Position',[140 29400 160
32760]);
Post by Christophe Boudrie
(my grid spacing is =20)
real_bus_position=get_param(mybus_selector,'Position');
I get: real_bus_position=[[140 0 160 3400]];
Which is very different from what I asked for.
I want to understand the reason of this difference, I
need
Post by Christophe Boudrie
to manage automatically this positionning.
Thanks,
CB.
Christophe Boudrie
2007-10-18 14:21:01 UTC
Permalink
Thank you for answering,

The limit of coordinates is 32767, (see in help, on
parameter 'Position' for standard blocks). However when I
perform this command NO warning message or error message is
displayed on the matlab command window! Everything looks
alright but it is not!

regards;
CB.
Post by Fangjun Jiang
There is a limit on the maximum value of those
coordinates. I don't remember though. Try your command
individually at the command line and see what message you
got from Simulink. I remember it tells you the limit
value.
Post by Fangjun Jiang
Post by Christophe Boudrie
Hi,
I have some strange behaviour with simulink when I try
to
Post by Christophe Boudrie
position some blocks by using command line.
I try to place a bus selector block,
set_param(mybus_selector,'Position',[140 29400 160
32760]);
Post by Christophe Boudrie
(my grid spacing is =20)
real_bus_position=get_param(mybus_selector,'Position');
I get: real_bus_position=[[140 0 160 3400]];
Which is very different from what I asked for.
I want to understand the reason of this difference, I
need
Post by Christophe Boudrie
to manage automatically this positionning.
Thanks,
CB.
Fangjun Jiang
2007-10-18 15:18:56 UTC
Permalink
Well, it works on my computer. I have Matlab 2006b. Here
is the diary.

It becomes a black bar on the left bottom of the Simulink
window. But then the Simulink window seems to be freezed.
I can't let the Simulink window show up again. I have to
kill Matlab.
block=gcb
block =

untitled/Bus
Selector
get_param(block,'Position')
ans =

175 26 180 64
set_param(block,'Position',[140 29400 160 32760])
get_param(block,'Position')
ans =

140 29400 160 32760
Michael Bölling
2007-10-25 20:06:20 UTC
Permalink
You can also get problems when you add a block with the
maximum dimension. See this example (matlab 2006a+)

function test_sfun_size
sys = 'sys';
new_system( sys ,'Model');
open_system(sys);
pos = [100 0 200 32767];
blk_name = [sys '/blk'];
add_block('built-in/Subsystem', blk_name, 'Position', pos);
new_pos = get_param(blk_name,'Position');
% This results in: 100 15 200 32782
% That exceeds the limits and block is wrongly displayed.


What is also not very funny is that the position of your
block changes when you add inports or outport, so you can
not be shure where your block actually is. It happens to me
that it moves to the side with negative y values when I
added a lot of ports.
Michael Bölling
2007-10-25 20:07:09 UTC
Permalink
You can also get problems when you add a block with the
maximum dimension. See this example (matlab 2006a+)

function test_sfun_size
sys = 'sys';
new_system( sys ,'Model');
open_system(sys);
pos = [100 0 200 32767];
blk_name = [sys '/blk'];
add_block('built-in/Subsystem', blk_name, 'Position', pos);
new_pos = get_param(blk_name,'Position');
% This results in: 100 15 200 32782
% That exceeds the limits and block is wrongly displayed.


What is also not very funny is that the position of your
block changes when you add inports or outport, so you can
not be shure where your block actually is. It happens to me
that it moves to the side with negative y values when I
added a lot of ports.

Loading...