フィルターのクリア

How to put radiobutton in GUI to cycle if?

3 ビュー (過去 30 日間)
Veronika
Veronika 2015 年 3 月 9 日
コメント済み: Veronika 2015 年 3 月 10 日
Dear all,
I have in my GUI 5 radiobuttons and pushbutton. The user selects the radiobutton (for example radiobutton1). And then press pushbutton, which should perform the function of radiobutton(radiobutton1).
This is my code:
function pushbutton1_Callback(hObject, eventdata, handles)
if radiobutton1 executes
load ('net.mat')
load ('trenovaci_modely1_velky')
disp('Neuronová síť byla načtena.')
disp('Trénovací modely byly načteny.')
else
load('trenovaci_modely1_velky')
disp('Trénovací modely byly načteny.')
P = [velky_tvar{1,:}];
T = [velky_tvar{2,:}];
net = newrb(P,T,0,0.3)
end
save net net
disp('Neuronová síť byla uložena.')
Comand Window returns errors. Please, advise me.
  2 件のコメント
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015 年 3 月 9 日
編集済み: Giorgos Papakonstantinou 2015 年 3 月 9 日
Veronika what do you mean with the statement:
if radiobutton1 executes?
Do you want to check if radiobutton 1 is selected at the beginning pushbutton1_Callback?
Veronika
Veronika 2015 年 3 月 9 日
Yes, that is what I need.

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

採用された回答

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015 年 3 月 9 日
If we assume the radiobutton handle variable name is radio then your if statement inside the pushbutton1_Callback should be:
if get(radio, 'Value')==1
...
else
...
end
And with else you mean every other possible situation.
  3 件のコメント
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015 年 3 月 9 日
編集済み: Giorgos Papakonstantinou 2015 年 3 月 9 日
If you call it radio
radio = uicontrol('Style', 'radiobutton')
Then Matlab will not complain if you say:
get(radio, 'Value')
Replace radio with the name that YOU have given to radiobutton1.
If you have created it from guide then check the Tag name of this button:
In this example the name is radiobutton1. You should write:
get(handles.radiobutton1, 'Value')
Veronika
Veronika 2015 年 3 月 10 日
Thank you, it works great.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by