フィルターのクリア

Use of the Pop-up menu in a GUI

2 ビュー (過去 30 日間)
Guillermo Soriano
Guillermo Soriano 2013 年 8 月 23 日
Hi: I am developping a gui with the function pop-up menú but it does not work. This is the code:
function Vt_Callback(hObject, eventdata, handles)
% hObject handle to Vt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns Vt contents as cell array
% contents{get(hObject,'Value')} returns selected item from Vt
switch get(handles.Vt_Callback,'Value')
case ('Alta')
Vt = 34;
case ('Media')
Vt = 23;
case ('Baja')
Vt = 18;
end
handles.data.Vt = Vt;
guidata(hObject, handles)
But when I run it, appears following message:
Vt =
NaN
NaN
NaN
Warning: Rank deficient, rank = 0, tol = NaN. > In TDC>pushbutton3_Callback at 422 In gui_mainfcn at 96 In TDC at 42
I will appreciate very much to someone could explain me where is my error regards Willy

回答 (2 件)

Sabarinathan Vadivelu
Sabarinathan Vadivelu 2013 年 8 月 23 日
get(handles.Vt_Callback,'Value')
This returns the value.
Try using:
get(handles.Vt_Callback,'String')
  1 件のコメント
Guillermo Soriano
Guillermo Soriano 2013 年 8 月 23 日
Hi: Thank you for your quick response. But I got almost the same error: Vt =
NaN
NaN
NaN
Warning: Rank deficient, rank = 0, tol = NaN. I did exactly what you sent. Regards Willy

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


David Sanchez
David Sanchez 2013 年 8 月 23 日
Instead of using the string of the selected item, use its position on the list:
switch get(handles.Vt_Callback,'Value')
case 1 %('Alta')
Vt = 34;
case 2 %('Media')
Vt = 23;
case 3 %('Baja')
Vt = 18;
end
  1 件のコメント
Guillermo Soriano
Guillermo Soriano 2013 年 8 月 23 日
Hi: thank you for your quick assistance. Unfortunately I got following message: Error: File: TDC.m Line: 224 Column: 19 Expression or statement is incomplete or incorrect.
Error in @(hObject,eventdata)TDC('pushbutton3_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
It refers to the statement : case %('Alta') Regards Willy

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

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by