how can i change the value of a variable with a slider in matlab designer?

71 ビュー (過去 30 日間)
Matlab_Beginner
Matlab_Beginner 2022 年 9 月 8 日
編集済み: Matlab_Beginner 2022 年 9 月 12 日
hello, i want to change a value of a variable in my matlab script while running it with a slider that i build in matlab designer.
im quit new to designer, can anyone help me out?
Thanks in advance

回答 (2 件)

Catalytic
Catalytic 2022 年 9 月 8 日
編集済み: Catalytic 2022 年 9 月 8 日
Here is a doc page talking about the general process of writing component callbacks in appdesigner. In this particular section, there is an example dealing with a slider callback.
  1 件のコメント
Matlab_Beginner
Matlab_Beginner 2022 年 9 月 8 日
編集済み: Matlab_Beginner 2022 年 9 月 9 日
so what i basically want to do is when i push the start button, my script runs and i can change the value of N as i need.
while true
% code
% Slider value (N) varies when i change it
% code
end
I hope this clarifies the Situation a bit better.
Thanks in advance

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


Steven Lord
Steven Lord 2022 年 9 月 9 日
Rather than changing the value of a fixed variable I would likely retrieve the Value property of the slider object whenever I need to use its value. This way I would be sure to always have the current value of the slider.
  1 件のコメント
Matlab_Beginner
Matlab_Beginner 2022 年 9 月 12 日
編集済み: Matlab_Beginner 2022 年 9 月 12 日
do i need to store the value of the Slider as a propertie in order to share within the code?
will this work ? (i'm new to designer..)
properties (Access = public)
Slider_CurrentValue % Description
end
function SliderValueChanging(app, event)
Slider_CurrentValue = event.Value;
end
% Buttonpushed_to_start
while true
m=x*(app.Slider_currentValue);
%code...
end

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

カテゴリ

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