Buongiorno a tutti,
sto iniziando a lavorare con la GUI di Matlab.
Attraverso il comando GUIDE ho creato la mia GUI dove vorrei che matlab riconosca due valori numerici (EDIT TEXT) e attraverso un PUSHBUTTON vada a mostrarmi la differenza tra i due valori.
Questo è il mio script.
function EditBox_W_Callback(hObject, eventdata, handles)
% hObject handle to EditBox_W (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
handles = guidata (hObject);
W = get (hObject, 'String');
W = str2double (R);
handles.EditBox_W = W;
guidata (hObject, handles);
% Hints: get(hObject,'String') returns contents of EditBox_W as text
% str2double(get(hObject,'String')) returns contents of EditBox_W as a double
% --- Executes during object creation, after setting all properties.
function EditBox_W_CreateFcn(hObject, eventdata, handles)
% hObject handle to EditBox_W (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit 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
function RE_Callback(hObject, eventdata, handles)
% hObject handle to RE (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
handles = guidata (hObject);
% Hints: get(hObject,'String') returns contents of RE as text
% str2double(get(hObject,'String')) returns contents of RE as a double
R = get (hObject, 'String');
R = str2double (R);
handles.RE = R;
guidata (hObject, handles);
% --- Executes during object creation, after setting all properties
function RE_CreateFcn(hObject, eventdata, handles)
% hObject handle to RE (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit 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
% --- Executes during object creation, after setting all properties.
function textId_CreateFcn(hObject, eventdata, handles);
% hObject handle to textId (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes on button press in pushbuttonRW.
function pushbuttonRW_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonRW (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
handles = guidata (hObject);
@ pushbuttonRW_Callback;
R = handles.RE;
W = handles.EditBox_W;
value = R - W;
set (handles.EditBox_RW, 'String', value);
L'errore che restituisce Matlab è il seguente:
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)GUI_potenziostato('pushbuttonRW_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Cosa devo fare?
Grazie.