フィルターのクリア

Changing slider limit in gui

39 ビュー (過去 30 日間)
Pranaya Kansakar
Pranaya Kansakar 2020 年 5 月 5 日
編集済み: Pranaya Kansakar 2020 年 5 月 5 日
is there anyway i could get the slider to update the limit to the image count Ct?
It seems that the app.Slider.Limits only accepts numerical values - at the moment it is set at 2. How can in incorperate the .Count function into the slider limit so the limit automatically updates with the value of .Count should i decide to import another file with a different .Count value?
How can I add a listener function here also?
Imported imageSet code
% Button pushed function: LoadImageButton
function LoadImageButtonPushed(app, event)
global Ct
imgSetVector = imageSet(uigetdir(''),'recursive');
Z = read(imgSetVector,1);
Ct = imgSetVector.Count;
imshow(Z,'Parent',app.UIAxes)
Slider Code
app.Slider = uislider(app.UIFigure);
app.Slider.Limits = [1 2]; **
app.Slider.MajorTicks = [];
app.Slider.MajorTickLabels = {''};
app.Slider.ValueChangedFcn = createCallbackFcn(app, @SliderValueChanged, true);
app.Slider.MinorTicks = [];
app.Slider.Position = [296 36 321 3];
app.Slider.Value = 1;
Thanks!

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 5 日
Try to set the slider limit after this line
Ct = imgSetVector.Count;
app.Slider.Limits(2) = Ct;
  11 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 5 月 5 日
The valueChanging callback for uislider does not require lifting the mouse button. Read here: https://www.mathworks.com/help/releases/R2020a/matlab/ref/uislider.html#buicpgg-1_sep_shared-ValueChangingFcn.
Why are you creating the app in a script? Isn't it easier to use the app-designer?
Pranaya Kansakar
Pranaya Kansakar 2020 年 5 月 5 日
編集済み: Pranaya Kansakar 2020 年 5 月 5 日
I didn't realise that you could use the code in app-designer as well.
I've implemented it in app-designer and it works great!
Thanks!
I guess this was a trivial issue.
I attach my interpretation of the app if anyone else in the future stumbles across the same problem.
*it's laggy...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by