how i use slider rang in GUI?

6 ビュー (過去 30 日間)
yasmeen hadadd
yasmeen hadadd 2025 年 6 月 25 日
コメント済み: Abhishek 2025 年 7 月 2 日
hi
i need a help in GUI
i use slider rang to select period to diplay at axies , but the value not changed
where N4 is signal that load from file.
function SelectDataPeriodSliderValueChanging(app, event)
global N4
value = app.SelectDataPeriodSlider.Value;
segment= N4(value*200:(value*200)+999);
time_seg=0:1/200:5-(1/200);
plot(time_seg,segment,'Parent',app.UIAxes)
end
  2 件のコメント
yasmeen hadadd
yasmeen hadadd 2025 年 6 月 25 日
200 is the sampling freqency
Cris LaPierre
Cris LaPierre 2025 年 6 月 25 日
This can happen depending on the stepsize of your slider and the frequency of your signal.
As coded, the x axis will always be 0-5.
Consider sharing your signal file (attach using the paperclip icon) and slider settings (Limits and Step values)

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

回答 (1 件)

Abhishek
Abhishek 2025 年 7 月 1 日
In your code, you are using the 'ValueChangingFcn' callback but accessing the slider value using 'app.SelectDataPeriodSlider.Value'. As per the official documentation, the correct way to access the current slider value in 'ValueChangingFcn' is through the 'event' object passed to the callback, using the ‘event.Value’.
In App Designer, the argument is called ‘event’. You can query the object properties using dot notation. For example, ‘event.Value’ returns the current value of the slider.
Replace this line in you code:
value = app.SelectDataPeriodSlider.Value;
with this:
value = event.Value;
This ensures that your plot responds in real time as the slider is dragged.
You can refer to the official documentation of MATLAB:
This MATLAB Answer will help you when to select ‘ValueChangedFcn’ and ‘ValueChangingFcn’: https://www.mathworks.com/matlabcentral/answers/458098-difference-between-valuechangedfcn-valuechangingfcn#answer_371994
  2 件のコメント
yasmeen hadadd
yasmeen hadadd 2025 年 7 月 2 日
Thank you for your help
Abhishek
Abhishek 2025 年 7 月 2 日
Hi @yasmeen hadadd, if it helps, could you accept the answer.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by