How to move slider-bar with a step-size of two?

조회 수: 1 (최근 30일)
John Doe
John Doe 2020년 5월 17일
댓글: Rik 2020년 5월 18일
Hey there everyone. I have a slider which I want to increase like 1:2:10 by dragging the bar with mouse. How can I accomplish that?
Thanks in advance!
  댓글 수: 1
Rik
Rik 2020년 5월 18일
I don't know if you have already come across this page, but especially since GUIDE is going to be removed from Matlab, here are some useful tips: https://www.mathworks.com/matlabcentral/answers/483657-how-to-create-a-gui

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

채택된 답변

Rik
Rik 2020년 5월 17일
편집: Rik 2020년 5월 17일
Round the Value property to the nearest value in your array in the callback function.
allowed_vals=1:2:10;%better: store this in the guidata struct
val=3.2;%val=get(hObject,'Value');
[~,idx]=min(abs(allowed_vals-val));
val_rounded=allowed_vals(idx);
%set(hObject,'Value',val_rounded);
disp(val_rounded)
  댓글 수: 4
John Doe
John Doe 2020년 5월 18일
I see. Thanks for the explanation.
Actually, I am trying to pass this slider value to a filter.
x = imboxfilt(Dummyimage,sliderval)
When I increase the slider, the picture gets blurred. But then when I decrease the value, the blurness does not decrease. I want the blur amount to vary with the slider value.
Is it because the pixels are already averaged and cannot be reverted back? Is there a way to solve this issue? Thanks.
Rik
Rik 2020년 5월 18일
You need to blur the original image, so you will have to store both the original and the processed version.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by