gui分段函数.docx
《gui分段函数.docx》由会员分享,可在线阅读,更多相关《gui分段函数.docx(21页珍藏版)》请在冰点文库上搜索。
gui分段函数
functionvarargout=workout(varargin)
%WORKOUTM-fileforworkout.fig
%WORKOUT,byitself,createsanewWORKOUTorraisestheexisting
%singleton*.
%
%H=WORKOUTreturnsthehandletoanewWORKOUTorthehandleto
%theexistingsingleton*.
%
%WORKOUT('CALLBACK',hObject,eventData,handles,...)callsthelocal
%functionnamedCALLBACKinWORKOUT.Mwiththegiveninputarguments.
%
%WORKOUT('Property','Value',...)createsanewWORKOUTorraisesthe
%existingsingleton*.Startingfromtheleft,propertyvaluepairsare
%appliedtotheGUIbeforeworkout_OpeningFcngetscalled.An
%unrecognizedpropertynameorinvalidvaluemakespropertyapplication
%stop.Allinputsarepassedtoworkout_OpeningFcnviavarargin.
%
%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone
%instancetorun(singleton)".
%
%Seealso:
GUIDE,GUIDATA,GUIHANDLES
%Edittheabovetexttomodifytheresponsetohelpworkout
%LastModifiedbyGUIDEv2.528-Aug-201520:
29:
52
%Begininitializationcode-DONOTEDIT
gui_Singleton=1;
gui_State=struct('gui_Name',mfilename,...
'gui_Singleton',gui_Singleton,...
'gui_OpeningFcn',@workout_OpeningFcn,...
'gui_OutputFcn',@workout_OutputFcn,...
'gui_LayoutFcn',[],...
'gui_Callback',[]);
ifnargin&&ischar(varargin{1})
gui_State.gui_Callback=str2func(varargin{1});
end
ifnargout
[varargout{1:
nargout}]=gui_mainfcn(gui_State,varargin{:
});
else
gui_mainfcn(gui_State,varargin{:
});
end
%Endinitializationcode-DONOTEDIT
%---Executesjustbeforeworkoutismadevisible.
functionworkout_OpeningFcn(hObject,eventdata,handles,varargin)
%Thisfunctionhasnooutputargs,seeOutputFcn.
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%varargincommandlineargumentstoworkout(seeVARARGIN)
%Choosedefaultcommandlineoutputforworkout
handles.output=hObject;
%Updatehandlesstructure
guidata(hObject,handles);
%UIWAITmakesworkoutwaitforuserresponse(seeUIRESUME)
%uiwait(handles.figure1);
%---Outputsfromthisfunctionarereturnedtothecommandline.
functionvarargout=workout_OutputFcn(hObject,eventdata,handles)
%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Getdefaultcommandlineoutputfromhandlesstructure
varargout{1}=handles.output;
functioninput_Callback(hObject,eventdata,handles)
%hObjecthandletoinput(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
input=str2num(get(hObject,'String'));
if(isempty(input))
set(hObject,'String','')
end
guidata(hObject,handles);
%Hints:
get(hObject,'String')returnscontentsofinputastext
%str2double(get(hObject,'String'))returnscontentsofinputasadouble
%---Executesduringobjectcreation,aftersettingallproperties.
functioninput_CreateFcn(hObject,eventdata,handles)
%hObjecthandletoinput(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled
%Hint:
editcontrolsusuallyhaveawhitebackgroundonWindows.
%SeeISPCandCOMPUTER.
ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%---Executesonbuttonpressinv.
functionv_Callback(hObject,eventdata,handles)
%hObjecthandletov(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
a=get(handles.input,'String');
x1=get(handles.input1,'String');
y1=get(handles.input2,'String');
x2=get(handles.input3,'String');
y2=get(handles.input4,'String');
x3=get(handles.input5,'String');
y3=get(handles.input6,'String');
x4=get(handles.input7,'String');
y4=get(handles.input8,'String');
x5=get(handles.input9,'String');
y5=get(handles.input10,'String');
x6=get(handles.input11,'String');
y6=get(handles.input12,'String');
u1=str2num(x3);
u2=str2num(y3);
u3=str2num(x4);
u4=str2num(y4);
u5=str2num(x5);
u6=str2num(y5);
u7=str2num(x6);
u8=str2num(y6);
q=str2num(a);
w=str2num(x1);
e=str2num(y1);
r=str2num(x2);
t=str2num(y2);
x=[wu1u3u5u7r];
y=[eu2u4u6u8t];
m=diff(y)./diff(x);
n=interp1(x,y,q);
h=num2str(n);
xielv=num2str(m);
set(handles.slope,'String',xielv);
set(handles.answer,'String',h);
guidata(hObject,handles);
axes(handles.axes1);
plot(x,y,'r')
set(gca,'xtick',[0:
150:
2500]);
set(gca,'xlim',[02000]);
holdon
fori=1:
length(x)
plot(x(i),y(i),'*')
str=['('num2str(x(i))','num2str(y(i))')'];
text(x(i),y(i),str)
end
%set(handles.axes,'position',[0,0,1000,1000]);
functioninput1_Callback(hObject,eventdata,handles)
%hObjecthandletoinput1(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
input1=str2num(get(hObject,'String'));
if(isempty(input1))
set(hObject,'String','')
end
guidata(hObject,handles);
%Hints:
get(hObject,'String')returnscontentsofinput1astext
%str2double(get(hObject,'String'))returnscontentsofinput1asadouble
%---Executesduringobjectcreation,aftersettingallproperties.
functioninput1_CreateFcn(hObject,eventdata,handles)
%hObjecthandletoinput1(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled
%Hint:
editcontrolsusuallyhaveawhitebackgroundonWindows.
%SeeISPCandCOMPUTER.
ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
functioninput2_Callback(hObject,eventdata,handles)
%hObjecthandletoinput2(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
input2=str2num(get(hObject,'String'));
if(isempty(input2))
set(hObject,'String','')
end
guidata(hObject,handles);
%Hints:
get(hObject,'String')returnscontentsofinput2astext
%str2double(get(hObject,'String'))returnscontentsofinput2asadouble
%---Executesduringobjectcreation,aftersettingallproperties.
functioninput2_CreateFcn(hObject,eventdata,handles)
%hObjecthandletoinput2(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled
%Hint:
editcontrolsusuallyhaveawhitebackgroundonWindows.
%SeeISPCandCOMPUTER.
ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
functioninput3_Callback(hObject,eventdata,handles)
%hObjecthandletoinput3(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
input3=str2num(get(hObject,'String'));
if(isempty(input3))
set(hObject,'String','')
end
guidata(hObject,handles);
%Hints:
get(hObject,'String')returnscontentsofinput3astext
%str2double(get(hObject,'String'))returnscontentsofinput3asadouble
%---Executesduringobjectcreation,aftersettingallproperties.
functioninput3_CreateFcn(hObject,eventdata,handles)
%hObjecthandletoinput3(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled
%Hint:
editcontrolsusuallyhaveawhitebackgroundonWindows.
%SeeISPCandCOMPUTER.
ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
functioninput4_Callback(hObject,eventdata,handles)
%hObjecthandletoinput4(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
input4=str2num(get(hObject,'String'));
if(isempty(input4))
set(hObject,'String','')
end
guidata(hObject,handles);
%Hints:
get(hObject,'String')returnscontentsofinput4astext
%str2double(get(hObject,'String'))returnscontentsofinput4asadouble
%---Executesduringobjectcreation,aftersettingallproperties.
functioninput4_CreateFcn(hObject,eventdata,handles)
%hObjecthandletoinput4(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled
%Hint:
editcontrolsusuallyhaveawhitebackgroundonWindows.
%SeeISPCandCOMPUTER.
ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
functioninput5_Callback(hObject,eventdata,handles)
%hObjecthandletoinput5(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Hints:
get(hObject,'String')returnscontentsofinput5astext
%str2double(get(hObject,'String'))returnscontentsofinput5asadouble
input5=str2num(get(hObject,'String'));
if(isempty(input5))
set(hObject,'String','')
end
guidata(hObject,handles);
%---Executesduringobjectcreation,aftersettingallproperties.
functioninput5_CreateFcn(hObject,