matlab习题第十章.docx

上传人:b****7 文档编号:23377532 上传时间:2023-05-16 格式:DOCX 页数:13 大小:17.91KB
下载 相关 举报
matlab习题第十章.docx_第1页
第1页 / 共13页
matlab习题第十章.docx_第2页
第2页 / 共13页
matlab习题第十章.docx_第3页
第3页 / 共13页
matlab习题第十章.docx_第4页
第4页 / 共13页
matlab习题第十章.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

matlab习题第十章.docx

《matlab习题第十章.docx》由会员分享,可在线阅读,更多相关《matlab习题第十章.docx(13页珍藏版)》请在冰豆网上搜索。

matlab习题第十章.docx

matlab习题第十章

第十章

实验指导

1.screen=get(0,'screensize');

W=screen(3);

>>H=screen(4);

>>figure('position',[0.2*H,0.2*H,0.5*W,0.3*H],'Name','设计菜单','numbertitle','off','menubar','none');

aa=['newitem'];

bb=[‘openitem’];

cc=[‘saveitem’];

dd=[‘helpitem’];

hfile=uimenu(gcf,'label','&File');)

uimenu(hfile,'label','new','call',msgbox(aa,'Title'),'set(save,''enable'',''off'')');

uimenu(hfile,’label’,’open’,’call’,msgbox(bb,’Title’),set(save,’’enable’’,’’off’’)’);

uimenu(hfile,’lable’,’save’,’call’,msgbox(cc,’Title’));

uimenu(gcf,’lable’,’&Exit’,’call’,close(gcf));

hhelp=uimenu(gcf,’label’,’&Help’);

uimenu(hhelp,’label’,’about,’’call’,msgbox(dd,’Title’),’set(save,’’enable’’,’’on’’))

2、

pdstart=uicontrol(gcf,'style','push','position',...

[50,5,60,25],'string','startplot',...

'callback','t=-pi:

pi/20:

pi;plot(t,t.*t)');

ptgrid=uicontrol(gcf,'style','toggle','position',...

[150,5,60,25],'string','grid','callback','grid');

htxt=uicontrol(gcf,'style','text','string',...

'coloroptions','position',[200,130,150,20]);

hr=uicontrol(gcf,'style','radio','string',...

'red','position',[200,100,150,25],'value',1,...

'callback',['set(hr,''value'',1);','set(hb,''value'',0);',...

'set(hy,''value'',0);','set(plot(t,t.*t),''color'',''R'')']);

hb=uicontrol(gcf,'style','radio','string',...

'blue','position',[200,75,150,25],'value',1,...

'callback',['set(hb,''value'',1);','set(hr,''value'',0);',...

'set(hy,''value'',0);','set(plot(t,t.*t),''color'',''B'')']);

hy=uicontrol(gcf,'style','radio','string',...

'yellow','position',[200,50,150,25],'value',1,...

'callback',['set(hy,''value'',1);','set(hr,''value'',0);',...

'set(hb,''value'',0);','set(plot(t,t.*t),''color'',''Y'')']);

3、

functionvarargout=duoxiangshiqiugen(varargin)

%DUOXIANGSHIQIUGENMATLABcodeforduoxiangshiqiugen.fig

%DUOXIANGSHIQIUGEN,byitself,createsanewDUOXIANGSHIQIUGENorraisestheexisting

%singleton*.

%

%H=DUOXIANGSHIQIUGENreturnsthehandletoanewDUOXIANGSHIQIUGENorthehandleto

%theexistingsingleton*.

%

%DUOXIANGSHIQIUGEN('CALLBACK',hObject,eventData,handles,...)callsthelocal

%functionnamedCALLBACKinDUOXIANGSHIQIUGEN.Mwiththegiveninputarguments.

%

%DUOXIANGSHIQIUGEN('Property','Value',...)createsanewDUOXIANGSHIQIUGENorraisesthe

%existingsingleton*.Startingfromtheleft,propertyvaluepairsare

%appliedtotheGUIbeforeduoxiangshiqiugen_OpeningFcngetscalled.An

%unrecognizedpropertynameorinvalidvaluemakespropertyapplication

%stop.Allinputsarepassedtoduoxiangshiqiugen_OpeningFcnviavarargin.

%

%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone

%instancetorun(singleton)".

%

%Seealso:

GUIDE,GUIDATA,GUIHANDLES

%Edittheabovetexttomodifytheresponsetohelpduoxiangshiqiugen

%LastModifiedbyGUIDEv2.528-May-201409:

58:

02

%Begininitializationcode-DONOTEDIT

gui_Singleton=1;

gui_State=struct('gui_Name',mfilename,...

'gui_Singleton',gui_Singleton,...

'gui_OpeningFcn',@duoxiangshiqiugen_OpeningFcn,...

'gui_OutputFcn',@duoxiangshiqiugen_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

 

%---Executesjustbeforeduoxiangshiqiugenismadevisible.

functionduoxiangshiqiugen_OpeningFcn(hObject,eventdata,handles,varargin)

%Thisfunctionhasnooutputargs,seeOutputFcn.

%hObjecthandletofigure

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%varargincommandlineargumentstoduoxiangshiqiugen(seeVARARGIN)

%Choosedefaultcommandlineoutputforduoxiangshiqiugen

handles.output=hObject;

%Updatehandlesstructure

guidata(hObject,handles);

%UIWAITmakesduoxiangshiqiugenwaitforuserresponse(seeUIRESUME)

%uiwait(handles.figure1);

 

%---Outputsfromthisfunctionarereturnedtothecommandline.

functionvarargout=duoxiangshiqiugen_OutputFcn(hObject,eventdata,handles)

%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);

%hObjecthandletofigure

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%Getdefaultcommandlineoutputfromhandlesstructure

varargout{1}=handles.output;

 

functionedit1_Callback(hObject,eventdata,handles)

%hObjecthandletoedit1(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%Hints:

get(hObject,'String')returnscontentsofedit1astext

%str2double(get(hObject,'String'))returnscontentsofedit1asadouble

 

%---Executesduringobjectcreation,aftersettingallproperties.

functionedit1_CreateFcn(hObject,eventdata,handles)

%hObjecthandletoedit1(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled

%Hint:

editcontrolsusuallyhaveawhitebackgroundonWindows.

%SeeISPCandCOMPUTER.

ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

 

%---Executesonbuttonpressinpushbutton1.

functionpushbutton1_Callback(hObject,eventdata,handles)

%hObjecthandletopushbutton1(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

com1=get(handles.edit1,'string');

A=str2mat(com1);

a=str2num(A)

X=roots(a)

set(handles.edit2,'string',num2str(X));

 

functionedit2_Callback(hObject,eventdata,handles)

%hObjecthandletoedit2(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%Hints:

get(hObject,'String')returnscontentsofedit2astext

%str2double(get(hObject,'String'))returnscontentsofedit2asadouble

 

%---Executesduringobjectcreation,aftersettingallproperties.

functionedit2_CreateFcn(hObject,eventdata,handles)

%hObjecthandletoedit2(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled

%Hint:

editcontrolsusuallyhaveawhitebackgroundonWindows.

%SeeISPCandCOMPUTER.

ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

functionvarargout=jizuobiaoquxian(varargin)

%JIZUOBIAOQUXIANMATLABcodeforjizuobiaoquxian.fig

%JIZUOBIAOQUXIAN,byitself,createsanewJIZUOBIAOQUXIANorraisestheexisting

%singleton*.

%

%H=JIZUOBIAOQUXIANreturnsthehandletoanewJIZUOBIAOQUXIANorthehandleto

%theexistingsingleton*.

%

%JIZUOBIAOQUXIAN('CALLBACK',hObject,eventData,handles,...)callsthelocal

%functionnamedCALLBACKinJIZUOBIAOQUXIAN.Mwiththegiveninputarguments.

%

%JIZUOBIAOQUXIAN('Property','Value',...)createsanewJIZUOBIAOQUXIANorraisesthe

%existingsingleton*.Startingfromtheleft,propertyvaluepairsare

%appliedtotheGUIbeforejizuobiaoquxian_OpeningFcngetscalled.An

%unrecognizedpropertynameorinvalidvaluemakespropertyapplication

%stop.Allinputsarepassedtojizuobiaoquxian_OpeningFcnviavarargin.

%

%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone

%instancetorun(singleton)".

%

%Seealso:

GUIDE,GUIDATA,GUIHANDLES

%Edittheabovetexttomodifytheresponsetohelpjizuobiaoquxian

%LastModifiedbyGUIDEv2.528-May-201409:

55:

56

%Begininitializationcode-DONOTEDIT

gui_Singleton=1;

gui_State=struct('gui_Name',mfilename,...

'gui_Singleton',gui_Singleton,...

'gui_OpeningFcn',@jizuobiaoquxian_OpeningFcn,...

'gui_OutputFcn',@jizuobiaoquxian_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

 

%---Executesjustbeforejizuobiaoquxianismadevisible.

functionjizuobiaoquxian_OpeningFcn(hObject,eventdata,handles,varargin)

%Thisfunctionhasnooutputargs,seeOutputFcn.

%hObjecthandletofigure

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%varargincommandlineargumentstojizuobiaoquxian(seeVARARGIN)

%Choosedefaultcommandlineoutputforjizuobiaoquxian

handles.output=hObject;

%Updatehandlesstructure

guidata(hObject,handles);

%UIWAITmakesjizuobiaoquxianwaitforuserresponse(seeUIRESUME)

%uiwait(handles.figure1);

 

%---Outputsfromthisfunctionarereturnedtothecommandline.

functionvarargout=jizuobiaoquxian_OutputFcn(hObject,eventdata,handles)

%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);

%hObjecthandletofigure

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%Getdefaultcommandlineoutputfromhandlesstructure

varargout{1}=handles.output;

 

%---Executesonbuttonpressinpushbutton1.

functionpushbutton1_Callback(hObject,eventdata,handles)

%hObjecthandletopushbutton1(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

com1=get(handles.edit1,'string');

com2=get(handles.edit2,'string');

com3=get(handles.edit3,'s

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 英语

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1