フィルターのクリア

Update slider Limits after loading data?

21 ビュー (過去 30 日間)
Ian
Ian 2024 年 1 月 6 日
回答済み: Voss 2024 年 1 月 7 日
I am using app designer and I created a slider called "FrameSelect".
The function called just before returns numFrames which I store to the app's properties. The line only works if I hard code the limits. How do I update the limits of this slider?
function OpenMenuSelected(app, event)
[file, path] = uigetfile('*.jpg;*.seq',"Select `.seq` file for analysis");
[app.imageSequence, app.minTemp, app.maxTemp, app.numFrames, app.frameRate] = load_image_sequence(app, strcat(path,file));
app.numFrames
app.FrameSelect.Value = 1;
limits = [1 app.numFrames]
app.FrameSelect.Limits = limits;
app.FrameSelect.MajorTicks = 1:15:app.numFrames;
notify(app.FrameSelect, 'ValueChanged');
end
'Limits' must be a 1-by-2 array of real finite numbers that are increasing.
limits =
1×2 int32 row vector
1 317
And yes, numFrames is an int32 value between [200, 1500] after the load_image call.
When I hard code in a value, there is no error.

採用された回答

Voss
Voss 2024 年 1 月 7 日
MATLAB doesn't appear to allow the Limits property of a uislider to take on int32 values, at least in R2016b.
So it's worth a shot to try casting the value to double before using it in Limits:
app.FrameSelect.Limits = [1 double(app.numFrames)];

その他の回答 (1 件)

Ian
Ian 2024 年 1 月 7 日
I created a min reproducable example (min_example.mlapp) that has no issues updating the sliders limits, so there must a problem with how the dll I am using is interfaced with Matlab.
In my code doing the following worked.
function OpenMenuSelected(app, event)
[file, path] = uigetfile('*.jpg;*.seq',"Select `.seq` file for analysis");
[app.imageSequence, app.minTemp, app.maxTemp, app.numFrames, app.frameRate] = load_image_sequence(app, strcat(path,file));
x = int2str(app.numFrames);
y = str2num(x);
UpdateSlider(app, y);
end
function UpdateSlider(app, maxFrame)
app.FrameSelect.Limits = [1 maxFrame];
app.FrameSelect.MajorTicks = 1:15:app.numFrames;
app.FrameSelect.Value = 1;
UpdateImage(app, 1);
end
I am going to change my load function to calculate the number of frames instead of using the dll's functions.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by