function varargout = fig2real(varargin)
% FIG2REAL M-file for fig2real.fig
% FIG2REAL, by itself, creates a new FIG2REAL or raises the existing
% singleton*.
%
% H = FIG2REAL returns the handle to a new FIG2REAL or the handle to
% the existing singleton*.
%
% FIG2REAL('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FIG2REAL.M with the given input arguments.
%
% FIG2REAL('Property','Value',...) creates a new FIG2REAL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before fig2real_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to fig2real_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 fig2real
% Last Modified by GUIDE v2.5 15-Nov-2007 01:47:46
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @fig2real_OpeningFcn, ...
'gui_OutputFcn', @fig2real_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 fig2real is made visible.
function fig2real_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 fig2real (see VARARGIN)
% Choose default command line output for fig2real
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes fig2real wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = fig2real_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 during object creation, after setting all properties.
function pic_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to pic_edit (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function pic_edit_Callback(hObject, eventdata, handles)
% hObject handle to pic_edit (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 pic_edit as text
% str2double(get(hObject,'String')) returns contents of pic_edit as a double
% --- Executes during object creation, after setting all properties.
function inp_pop_CreateFcn(hObject, eventdata, handles)
% hObject handle to inp_pop (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in inp_pop.
function inp_pop_Callback(hObject, eventdata, handles)
% hObject handle to inp_pop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns inp_pop contents as cell array
% contents{get(hObject,'Value')} returns selected item from inp_pop
% --- Executes during object creation, after setting all properties.
function x_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to x_edit (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function x_edit_Callback(hObject, eventdata, handles)
% hObject handle to x_edit (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 x_edit as text
% str2double(get(hObject,'String')) returns contents of x_edit as a double
% --- Executes during object creation, after setting all properties.
function y_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to y_edit (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function y_edit_Callback(hObject, eventdata, handles)
% hObject handle to y_edit (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 y_edit as text
% str2double(get(hObject,'String')) returns contents of y_edit as a double
% --- Executes on button press in start_push.
function start_push_Callback(hObject, eventdata, handles)
% hObject handle to start_push (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=get(handles.inp_pop,'value');
switch a
case 2
b=5
case 3
b=10 ;
case 4
b=15 ;
case 5
b=20 ;
case 6
b=25 ;
case 7
b=30 ;
end
axes(handles.photo_axes)
set(handles.pp_text,'visible','on')
pause(0.5)
set(handles.pp_text,'visible','off')
pause(0.5)
set(handles.pp_text,'visible','on')
pause(0.5)
set(handles.pp_text,'visible','off')
pause(0.5)
set(handles.pp_text,'visible','on')
pause(0.5)
set(handles.pp_text,'visible','off')
pause(0.5)
set(handles.pp_text,'visible','on')
pause(0.5)
set(handles.pp_text,'visible','off')
[x,y]=ginput(b);
x=x-min(x);
x=x./max(x);
xinterse=str2num(get(handles.x_edit,'string'));
xintersecmin=-xinterse(1);
xintersecmax=xinterse(2);
s=xintersecmax+xintersecmin;
x=x.*s;
x=x-xintersecmin;
y=y-max(y);
y=y./min(y);
yinterse=str2num(get(handles.y_edit,'string'));
yintersecmin=-yinterse(1);
yintersecmax=yinterse(2);
s=yintersecmax+yintersecmin;
y=y.*s;
y=y-yintersecmin;
axes(handles.real_axes);
x1=x';
y1=y';
x1=num2str(x1);
y1=num2str(y1);
set(handles.x1_edit,'string',x1);
set(handles.y1_edit,'string',y1);
plot(x,y)
grid
% --- Executes on button press in show_push.
function show_push_Callback(hObject, eventdata, handles)
% hObject handle to show_push (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=get(handles.fs_edit,'string');
axes(handles.photo_axes)
b=imread(a);
imshow(b)
axis off
pause(1)
set(handles.x_edit,'visible','on')
pause(1)
set(handles.y_edit,'visible','on')
pause(1)
set(handles.inp_pop,'visible','on')
pause(1)
set(handles.start_push,'visible','on')
% --- Executes on button press in modii.
function modii_Callback(hObject, eventdata, handles)
% hObject handle to modii (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.real_axes);
axis equal
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (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 edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function fit_slider_CreateFcn(hObject, eventdata, handles)
% hObject handle to fit_slider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function fit_slider_Callback(hObject, eventdata, handles)
% hObject handle to fit_slider (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
h=get(hObject,'Value');
set(handles.fit_edit,'string',h);
x=str2num(get(handles.x1_edit,'string'));
y=str2num(get(handles.y1_edit,'string'));
xx=linspace(x(1),x(end),100);
axes(handles.real_axes)
switch h
case 1
p=polyfit(x,y,1);
yy=polyval(p,xx);
plot(xx,yy,'g')
hold on
plot(x,y,'b')
hold off
grid on
set(handles.equ1_edit,'backgroundcolor',[0.5019607843137255 1 0.5019607843137255])
case 2
p=polyfit(x,y,2);
yy=polyval(p,xx);
plot(xx,yy,'k')
hold on
plot(x,y,'b')
hold off
grid on
set(handles.equ1_edit,'backgroundcolor',[0.5019607843137255 1 0.5019607843137255])
case 3
p=polyfit(x,y,3);
yy=polyval(p,xx);
plot(xx,yy,'c')
hold on
plot(x,y,'b')
hold off
grid on
set(handles.equ1_edit,'backgroundcolor',[0.5019607843137255 1 0.5019607843137255])
case 4
p=polyfit(x,y,4);
yy=polyval(p,xx);
plot(xx,yy,'r')
hold on
plot(x,y,'b')
hold off
grid on
set(handles.equ1_edit,'backgroundcolor',[0.5019607843137255 1 0.5019607843137255])
case 5
p=polyfit(x,y,5);
yy=polyval(p,xx);
plot(xx,yy,'m')
hold on
plot(x,y,'b')
hold off
grid on
set(handles.equ1_edit,'backgroundcolor',[0.5019607843137255 1 0.5019607843137255])
case 6
p=polyfit(x,y,6);
yy=polyval(p,xx);
plot(xx,yy,'y')
hold on
plot(x,y,'b')
hold off
grid on
set(handles.equ1_edit,'backgroundcolor',[0.5019607843137255 1 0.5019607843137255])
case 7
p=polyfit(x,y,7);
yy=polyval(p,xx);
plot(xx,yy,'g')
hold on
plot(x,y,'b')
hold off
grid on
set(handles.equ1_edit,'backgroundcolor',[0.5019607843137255 1 0.5019607843137255])
case 8
p=polyfit(x,y,8);
yy=polyval(p,xx);
plot(xx,yy,'k')
hold on
plot(x,y,'b')
hold off
grid on
set(handles.equ1_edit,'backgroundcolor',[0.5019607843137255 1 0.5019607843137255])
case 9
p=polyfit(x,y,9);
yy=polyval(p,xx);
plot(xx,yy,'m')
hold on
plot(x,y,'b')
hold off
grid on
set(handles.equ1_edit,'backgroundcolor',[0.5019607843137255 1 0.5019607843137255])
end
b=length(p);
syms x
for i=1:b
c(i)=p(i)*x^(b-i);
s(i)=sum(c);
end
equ=s(end);
q=vectorize(equ) ;
set(handles.equ1_edit,'string',q)
% --- Executes during object creation, after setting all properties.
function fit_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to fit_edit (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function fit_edit_Callback(hObject, eventdata, handles)
% hObject handle to fit_edit (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 fit_edit as text
% str2double(get(hObject,'String')) returns contents of fit_edit as a double
% --- Executes on button press in fit_check.
function fit_check_Callback(hObject, eventdata, handles)
% hObject handle to fit_check (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of fit_check
set(handles.inter_check,'value',0)
set(hObject,'Value',1)
set(handles.fit_slider,'enable','on')
set(handles.inp1_pop,'enable','off')
set(handles.equ1_edit,'string','','enable','on')
set(handles.equ_check,'enable','on')
% --- Executes on button press in inter_check.
function inter_check_Callback(hObject, eventdata, handles)
% hObject handle to inter_check (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of inter_check
set(handles.fit_check,'value',0)
set(hObject,'Value',1)
set(handles.fit_slider,'value',1)
set(handles.fit_slider,'enable','off')
set(handles.inp1_pop,'enable','on')
set(handles.fit_edit,'string','')
set(handles.equ1_edit,'string','','visible','off')
set(handles.equ_check,'value',0,'enable','off')
% --- Executes during object creation, after setting all properties.
function ino_pop_CreateFcn(hObject, eventdata, handles)
% hObject handle to ino_pop (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in ino_pop.
function ino_pop_Callback(hObject, eventdata, handles)
% hObject handle to ino_pop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns ino_pop contents as cell array
% contents{get(hObject,'Value')} returns selected item from ino_pop
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to fit_slider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to fit_slider (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function x1_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to x1_edit (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function x1_edit_Callback(hObject, eventdata, handles)
% hObject handle to x1_edit (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 x1_edit as text
% str2double(get(hObject,'String')) returns contents of x1_edit as a double
% --- Executes during object creation, after setting all properties.
function y1_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to y1_edit (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function y1_edit_Callback(hObject, eventdata, handles)
% hObject handle to y1_edit (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 y1_edit as text
% str2double(get(hObject,'String')) returns contents of y1_edit as a double
% --- Executes during object creation, after setting all properties.
function inp1_pop_CreateFcn(hObject, eventdata, handles)
% hObject handle to inp1_pop (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in inp1_pop.
function inp1_pop_Callback(hObject, eventdata, handles)
% hObject handle to inp1_pop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns inp1_pop contents as cell array
% contents{get(hObject,'Value')} returns selected item from inp1_pop
x=str2num(get(handles.x1_edit,'string'))
y=str2num(get(handles.y1_edit,'string'))
xx=linspace(x(1),x(length(x)),100);
h=get(hObject,'value');
switch h
case 1
yy=interp1(x,y,xx,'nearest');
case 2
yy=interp1(x,y,xx,'linear');
case 3
yy=interp1(x,y,xx,'spline');
case 4
yy=interp1(x,y,xx,'cubic');
end
axes(handles.real_axes)
plot(x,y,'*r')
grid on
hold on
plot(x,y,'b')
plot(xx,yy,'--k')
hold off
% --- Executes on button press in equ_check.
function equ_check_Callback(hObject, eventdata, handles)
% hObject handle to equ_check (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of equ_check
h=get(hObject,'Value');
switch h
case 0
set(handles.equ1_edit,'visible','off')
case 1
set(handles.equ1_edit,'visible','on')
end
% --- Executes during object creation, after setting all properties.
function equ1_edit_Callback(hObject, eventdata, handles)
% hObject handle to equ1_edit (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 equ1_edit as text
% str2double(get(hObject,'String')) returns contents of equ1_edit as a double
% --- Executes during object creation, after setting all properties.
function equ1_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to equ1_edit (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on button press in brows_push.
function brows_push_Callback(hObject, eventdata, handles)
% hObject handle to brows_push (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[a,b]=uigetfile('*.jpg','select your pic');
set(handles.pic_edit,'string',a)
s=[b a];
set(handles.fs_edit,'string',s)
% --- Executes during object creation, after setting all properties.
function fs_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to fs_edit (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function fs_edit_Callback(hObject, eventdata, handles)
% hObject handle to fs_edit (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 fs_edit as text
% str2double(get(hObject,'String')) returns contents of fs_edit as a double
% --- Executes when figure1 window is resized.
function figure1_ResizeFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)