Is it possible to change the increment value of a slider?

조회 수: 21 (최근 30일)
Ostap
Ostap 2025년 12월 10일 18:29
댓글: Walter Roberson 2025년 12월 11일 19:58
I needed a way to change value of a constant manualy, thus I added a slider, but because of specific conditions of my project I need the value of that constant to change with fixed increment, which in my case is 0.2. I tried to look up possible solutions or methods to control the increasing rate, but didn't find anything useful. Maybe I should use matlab code instead of simulink, but I have no clue how to realise it there eather. Any help would be appreciated.

답변 (1개)

Matthew Moschella
Matthew Moschella 2025년 12월 10일 19:49
If you are using a slider in Simulink the easiest approach may be to round the constant value from the slider to the nearest 0.2 and then feed that number in to whatever comes after your slider currently.
Ex:
Output from Slider, x = 3.478820.
Rounded_val = (x / 0.2) * 0.2
  댓글 수: 2
Ostap
Ostap 대략 14시간 전
편집: Ostap 대략 14시간 전
Yeah, that'll do I think. Thanks for the help
Walter Roberson
Walter Roberson 대략 13시간 전
Rounded_val = round(x / 0.2) * 0.2

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

카테고리

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

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by