Using a GUI with Matlab
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
abc abc
am 1 Apr. 2016
Bearbeitet: Stalin Samuel
am 1 Apr. 2016
Hi everybody, i'm just trying to create a GUI with MATLAB but i have a problem with the variable. This is my code :
if true
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (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 popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
a = get(handles.popupmenu2,'value')
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if (a == 1)
plot(sin(0:.1:10));
end
But MATLAB answered me
if true
Undefined function or variable 'a'.
Error in fit>pushbutton1_Callback (line 269)
if (a == 1)
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in fit (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)fit('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
end
Any ideas ?
Many thanks :)
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!