大神帮忙看下
sin按键的Callback
function pushbutton22_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if(handles.start)
content='0.';
set(handles.edit,'string',content);
guidata(hObject, handles);
else
content=get(handles.edit,'string');
text=strcat('sin(', content,')'); %把sin()写显示出来括号里是前面输入的内容
set(handles.edit,'string',text); %把内容显示出来
handles.point=1; %sin后不能在允许在输入点
handles.bracket=1; %sin()后不能直接跟数字
guidata(hObject, handles);
end
=号的Callback
function pushbutton24_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton24 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if(handles.start)
content='0.';
set(handles.edit,'string',content);
guidata(hObject, handles);
else
try %把显示的内容进行计算,把结果显示出来,如果出现计算错误,则不显示
content=get(handles.edit,'string');
result=eval(content); %对字符型表达式进行计算
set(handles.edit,'string',num2str(result));
handles.term=1;
handles.point=0;
guidata(hObject, handles);
catch
guidata(hObject, handles);
end
end
为什么计算出来的结果不对???
sin按键的Callback
function pushbutton22_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if(handles.start)
content='0.';
set(handles.edit,'string',content);
guidata(hObject, handles);
else
content=get(handles.edit,'string');
text=strcat('sin(', content,')'); %把sin()写显示出来括号里是前面输入的内容
set(handles.edit,'string',text); %把内容显示出来
handles.point=1; %sin后不能在允许在输入点
handles.bracket=1; %sin()后不能直接跟数字
guidata(hObject, handles);
end
=号的Callback
function pushbutton24_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton24 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if(handles.start)
content='0.';
set(handles.edit,'string',content);
guidata(hObject, handles);
else
try %把显示的内容进行计算,把结果显示出来,如果出现计算错误,则不显示
content=get(handles.edit,'string');
result=eval(content); %对字符型表达式进行计算
set(handles.edit,'string',num2str(result));
handles.term=1;
handles.point=0;
guidata(hObject, handles);
catch
guidata(hObject, handles);
end
end
为什么计算出来的结果不对???