필터 지우기
필터 지우기

How to change Horizontal size of a Constant block based on the "Value" of the block in order to make the value visible

조회 수: 4 (최근 30일)
If block size is small, constant value is not visible, it shows the value as -C-. To avoid this -c-, i need to control the size based on the value programmatically.

답변 (3개)

Anthony Poulin
Anthony Poulin 2015년 7월 3일
You have to use the command: set_param(Block,'Position',[50 100 80 130])
But I don't know how to dectect if the value is played on the block or if it is "-C-" which is displayed...
  댓글 수: 1
THAVAMANI
THAVAMANI 2015년 7월 3일
편집: THAVAMANI 2015년 7월 3일
If -C- is displayed, i need to change the Horizontal size according the value of the CONSTANT block. For eg. if the parameter value is "abc", width can be 40 PX. if it has "ASDFGHJKL" width should be high in order to display the whole value in simulink model instead of displaying -C-.

댓글을 달려면 로그인하십시오.


Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 3일
If you don't want to change the position of your block. Get it's actual position
pos=get_param('ModelName/Constant','Position');
Then just change the coordinate pos(3) and pos(4)
set_param('ModelName/Constant','Position' ,[pos(1:2) pos(3)+30,pos(4)+60])
  댓글 수: 1
THAVAMANI
THAVAMANI 2015년 7월 3일
My intention is to make the value visible in simulink model. If -C- is displayed, i need to change the Horizontal size according the value of the CONSTANT block. For eg. if the parameter value is "abc", width can be 40 PX. if it has "ASDFGHJKL" width should be high in order to display the whole value in simulink model instead of displaying -C-.

댓글을 달려면 로그인하십시오.


Anthony Poulin
Anthony Poulin 2015년 7월 3일
I understand what you want to do. And the command line that Abdelmalek and I provide you allows to resize a block. So you just have to create an algorithm which allow to detect if "-C-" is displayed on the block and if it is true, you resize this block with the command line.

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by