function varargout = untitled(varargin)
% UNTITLED MATLAB code for untitled.fig
%      UNTITLED, by itself, creates a new UNTITLED or raises the existing
%      singleton*.
%
%      H = UNTITLED returns the handle to a new UNTITLED or the handle to
%      the existing singleton*.
%
%      UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in UNTITLED.M with the given input arguments.
%
%      UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before untitled_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to untitled_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help untitled

% Last Modified by GUIDE v2.5 03-Jun-2016 01:20:19

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @untitled_OpeningFcn, ...
                   'gui_OutputFcn',  @untitled_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before untitled is made visible.
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to untitled (see VARARGIN)

% Choose default command line output for untitled
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in btn7.
function btn7_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), 7));

% hObject    handle to btn7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btn8.
function btn8_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), 8));
% hObject    handle to btn8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btn9.
function btn9_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), 9));
% hObject    handle to btn9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btn4.
function btn4_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), 4));
% hObject    handle to btn4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btn0.
function btn0_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), 0));
% hObject    handle to btn0 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btn6.
function btn6_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), 6));
% hObject    handle to btn6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btn5.
function btn5_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), 5));
% hObject    handle to btn5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btn3.
function btn3_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), 3));
% hObject    handle to btn3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btn2.
function btn2_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), 2));
% hObject    handle to btn2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btndot.
function btndot_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%s',str2num(str), '.'));
%str = get(handles.editanswer,'String');
%set(handles.editanswer, 'String', '.');
% hObject    handle to btndot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btn1.
function btn1_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), 1));
% hObject    handle to btn1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btnexp.
function btnexp_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), exp(1)));
% hObject    handle to btnexp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

 

function editanswer_Callback(hObject, eventdata, handles)
% hObject    handle to editanswer (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editanswer as text
%        str2double(get(hObject,'String')) returns contents of editanswer as a double


% --- Executes during object creation, after setting all properties.
function editanswer_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editanswer (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 on button press in btnmul.
function btnmul_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d*', str2num(str)));
% hObject    handle to btnmul (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btnminus.
function btnminus_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d-', str2num(str)));
% hObject    handle to btnminus (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btnplus.
function btnplus_Callback(hObject, eventdata, handles)
set(handles.editanswer, 'String', '+');
% hObject    handle to btnplus (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btndel.
function btndel_Callback(hObject, eventdata, handles)
% hObject    handle to btndel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btnequal.
function btnequal_Callback(hObject, eventdata, handles)
str=get(handles.editanswer,'String');
set(handles.editanswer,'String', eval(str));
% hObject    handle to btnequal (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btndiv.
function btndiv_Callback(hObject, eventdata, handles)
set(handles.editanswer, 'String', '/');
% hObject    handle to btndiv (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton20.
function pushbutton20_Callback(hObject, eventdata, handles)
str = get(handles.editanswer,'String');
set(handles.editanswer, 'String', sprintf('%d%d',str2num(str), pi));
% hObject    handle to pushbutton20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
계산기 만드는건데요

지금 숫자누르고 닷(btndot)을 누르고 다시 숫자버튼 누르면 닷이 없어지고 숫자만 나와요

예를 들면 1 누르고 . 누르고 3 누르면 화면에 13이 표시됩니다 ㅠㅠ

 

이거 어떻게 해결해야하죠??

. 뿐만아니라 사칙연산기호(btnmul, btnminus, btnplus, btndiv)도 다 같은현상을 보입니다ㅠㅠ

도와주세요 ㅠㅠ