數(shù)學實驗軟件_第1頁
數(shù)學實驗軟件_第2頁
數(shù)學實驗軟件_第3頁
數(shù)學實驗軟件_第4頁
數(shù)學實驗軟件_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、重慶科技學院數(shù)學實驗與數(shù)學軟件課程設計 課程名稱: 菜單與對話框設計 開課學期:_2014-2015-1 學 院:_ 數(shù)理學院 開課實驗室:_數(shù)學實驗與建模實驗室_學生姓名: 譚云文 專業(yè)班級: 應數(shù)13-2班 _ 學 號:_ _實驗十二 我們本次實驗做的是菜單與對話框設計,所謂菜單與對話框的設計包括在圖形用戶界面中。而圖形用戶界面是由窗口、菜單、對話框等各種圖形元素組成的用戶界面。因為在這種用戶界面中,用戶的操作既生動形象,又方便靈活,這是它的一大特點。在MATLAB中,基本的圖形用戶界面對象包含3類:用戶界面控件對象、下拉式菜單對象和快捷菜單對象,可以設計出界面友好、操作方便的圖形用戶界面

2、。其中MATLAB用戶菜單對象是圖形窗口的子對象,所以菜單設計總在某一個圖形窗口中進行。MATLAB的圖形窗口有自己的菜單欄。為了建立用戶自己的菜單系統(tǒng),可以先將圖形窗口的MenuBar屬性設置為none,以取消圖形窗口默認的菜單,然后再建立用戶自己的菜單。對話框是用戶與計算機進行信息交流的臨時窗口,在現(xiàn)代軟件中有著廣泛的應用。在軟件設計時,借助于對話框可以更好地滿足用戶操作需要,使用戶操作更加方面靈活。為了更便捷地進行用戶界面設計,MATLAB提供了圖形用戶界面開發(fā)環(huán)境,這使得界面設計在可視化狀態(tài)進行,設計過程中變得簡單直觀,實現(xiàn)了“所見即所得”。例1一、實驗目的 1. 掌握plot菜單的方

3、法。 2. 掌握建立控件對象的方法。 3. 掌握對話框設計的方法。二、實驗內(nèi)容 設計圖1所示的菜單。菜單條上僅有Plot菜單,其中有Sine Wave、Cosine Wave和Exit共3個命令。若選擇了其中的Sine Wave命令,則將繪制出正弦曲線;若選擇了其中的Cosine Wave命令,則將繪制出余弦曲線;如果選擇了Exit命令,則將關(guān)閉窗口。 程序如下:screen=get(0,ScreenSize);W=screen(3);H=screen(4); figure(Color,1,1,1,position,0.2*H,0.2*H,0.5*W,0.3*H,.Name,圖形演示系統(tǒng),Nu

4、mberTitle,off,Menubar,none);%plothplot=uimenu(gcf,Label,&Plot);uimenu(hplot,Label,Sine Wave,Call,.t=-pi:pi/20:pi;,plot(t,sin(t);,.set(hgon,Enable,on);,.set(hgoff,Enable,on);,.set(hbon,Enable,on);,.set(hboff,Enable,on););uimenu(hplot,Label,Cosine Wave,Call,.t=-pi:pi/20:pi;,plot(t,cos(t);,.set(hgon,En

5、able,on);,.set(hgoff,Enable,on);,.set(hbon,Enable,on);,.set(hboff,Enable,on);); uimenu(hplot,Label,&Exit,Call,close(gcf);三、運行結(jié)果 1.點擊SineWave函數(shù)將出現(xiàn)我們所需要的圖像,如圖:2點擊CosineWave函數(shù)將出現(xiàn)我們所需要的圖像,如圖:3.點擊Exit命令,這個窗口將會關(guān)閉。例5一、實驗目的 1. 掌握圖形用戶界面(GUI)設計的模板和窗口。 2. 掌握GUI可視化設計工具。二、實驗內(nèi)容采用圖形用戶界面,從鍵盤輸入?yún)?shù)a、b、n的值,考察參數(shù)對極坐標曲線rh

6、o=a*cos(b+n*theta)的影響。三、運行步驟1.打開MATLAB,選擇File命令下的New,建立GUI界面,如下圖:2.建立GUI界面,然后添加相應按鈕:,分別更改其代碼為a,b,n。則出現(xiàn):,刪除其代碼,則為:不做處理,繪制其畫圖區(qū)域大?。禾砑永L圖按鈕:,更改代碼為:繪制圖像。處理好后完整如下圖:3.在此窗口中的View中選擇M-file Editor,即出現(xiàn)相應的程序代碼:4.然后添加極坐標曲線pho=acos(b+n*theta)程序(代碼),如下:function varargout = untitled5(varargin)% UNTITLED5 M-file for

7、untitled5.fig% UNTITLED5, by itself, creates a new UNTITLED5 or raises the existing% singleton*.% H = UNTITLED5 returns the handle to a new UNTITLED5 or the handle to% the existing singleton*.% UNTITLED5(CALLBACK,hObject,eventData,handles,.) calls the local% function named CALLBACK in UNTITLED5.M wi

8、th the given input arguments.% UNTITLED5(Property,Value,.) creates a new UNTITLED5 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before untitled5_OpeningFunction gets called. An% unrecognized property name or invalid value makes property app

9、lication% stop. All inputs are passed to untitled5_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Copyright 2002-2003 The MathWorks, Inc.% Edit the above text to modify the response to h

10、elp untitled5% Last Modified by GUIDE v2.5 08-Jan-2015 16:30:47% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, untitled5_OpeningFcn, . gui_OutputFcn, untitled5_OutputFcn, . gui_LayoutFcn, , . gui_Cal

11、lback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before untitled5 is made visible.function untitl

12、ed5_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

13、5 (see VARARGIN)% Choose default command line output for untitled5handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes untitled5 wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.funct

14、ion varargout = untitled5_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 comm

15、and line output from handles structurevarargout1 = handles.output;function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (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

16、,String) returns contents of edit1 as text% str2double(get(hObject,String) returns contents of edit1 as a double% - Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defi

17、ned 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,defaultUicontrolBackgroun

18、dColor);endfunction edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (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 edit2 as text% str2double(

19、get(hObject,String) returns contents of edit2 as a double% - Executes during object creation, after setting all properties.function edit2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - hand

20、les 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);endfunction edit3_Callback(hObject, eventdata,

21、handles)% hObject handle to edit3 (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 edit3 as text% str2double(get(hObject,String) returns contents of edit3 as a double% - Executes during object creation, after setting all properties.function edit3_CreateFcn(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論