Changing significant digits of constant block

조회 수: 6 (최근 30일)
Ani R
Ani R 2022년 10월 23일
댓글: Ani R 2022년 10월 31일
Hi all, I have a basic question. I would like to reduce the number of significant digits in the constant block in Simulink. But I do not know how to do so. Can someone help?
Thanks.

채택된 답변

Andy Bartlett
Andy Bartlett 2022년 10월 24일
편집: Andy Bartlett 2022년 10월 24일
The constant block is showing the text that is entered for the parameter, and is not showing the evaluated numeric value. You do not have control over that behavior of the constant block.
To customize things, you could put a mask on top of the constant block.
Then using the Mask's Initialization code, you could change the value coming from the mask to some quantized value that the mask passes down to the underlying constant block. For example:
desiredInverseValueSpacing = 1000;
valForConstBlock = round(valFromMaskDialog * desiredInverseValueSpacing) / desiredInverseValueSpacing;
% where valForConstBlock is the text entered on the underly constant blocks
% for the 'Constant value:" parameter
Using Mask's MaskDisplay (aka Icon) code, you could use text manipulation techniques to get the specific text you prefer.
For example:
fprintf(num2str(valForConstBlock,6))

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 10월 23일
Right click the block, "open", and edit the text version of the constant.
  댓글 수: 3
Walter Roberson
Walter Roberson 2022년 10월 24일
I believe that Knobs are used to control Parameters, not Constant Block.
Ani R
Ani R 2022년 10월 31일
I see, thanks.

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

카테고리

Help CenterFile Exchange에서 Scopes and Data Logging에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by