ImageVerifierCode 换一换
格式:DOCX , 页数:16 ,大小:192.46KB ,
资源ID:4486994      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4486994.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(MATLAB课程设计报告.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

MATLAB课程设计报告.docx

1、MATLAB课程设计报告MATLAB课程设计报告模板MATLAB课程设计报告设计题目: 函数的定积分与图像的保存 学生姓名: 陈秀 学生学号: 2009045444014 专业班级: 09通信工程(师范) 答辩时间: 2011年6月3日 指导教师: 冯明库 广东技术师范学院电子与信息学院一、设计目的及意义 运用函数quad8 求已知函数在不同上下限内的定积分,并在坐标轴上显示出函数图形,利用这种方法有利于我们更加方便的计算定积分,且准确地画出函数图像。二、设计任务及指标(1)运用函数quad8 求y=sin(x)2在不同的区间的积分值;(2)在坐标轴画出函数y=sin(x)2的图像;(3)实现

2、保存函数图像的功能。三、设计过程 3.1设计主界面介绍建立一个默认的图形用户界面,保存为jifen.fig文件,在布局编辑器中布置控件:(1)建立一个坐标轴对象,显示函数图像;(2)建立三个按钮,分别用来求函数积分,保存图像和关闭程序;(3)建立二个可编辑文本框,分别用来输入积分的上下限a和b;(4)建立五个静态文本框,显示相应控件的提示和积分结果;(5)建立一个panel控件。界面设计如图1所示图1控件布局设置控件的相关属性:(1)设置三个按钮的Tag标识分别为:jifen_pushbutton, close_pushbutton, save_pushbutton;(2)设置两个可编辑文本框

3、的Tag的标识分别为:a_edit,b_edit,用来输入积分的上下限;(3)设置界面最底下的静态文本标签Tag标识为jifen_text,用来显示积分结果。最终界面显示如图2所示图2最终界面显示3.2添加菜单3.2.1添加文件菜单建立一级菜单“文件”,在其下设置两个子菜单“积分”和“退出”。“积分”的Tag设置为jifen_menu,“退出”的Tag设置为close_menu。3.2.2添加选择菜单建立一级菜单“选择”在其下设置三个子菜单“网格”,“边框”,“颜色”(1)在“网格”下设置二个三级菜单“显示”,“隐藏”,“显示”的Callback设置为grid on,“隐藏“设置”为grid

4、off;(2)在“边框”下设置二个三级菜单“显示”,“隐藏”,“显示”的Callback设置为box on,“隐藏“设置”为box off;(3)在“颜色”下设置三个三级菜单“蓝色”,“黄色”,“绿色”,“蓝色”的Callback设置为set(gcf,Color,b),“黄色”的Callback设置为set(gcf,Color,y);“绿色”的Callback设置为set(gcf,Color,g)。如图3所示图3添加菜单3.3编写代码(1)赋予a,b初始值function jifen_OpeningFcn(hObject, eventdata, handles, varargin)% This

5、 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 jifen (see VARARGIN)% Choose default command line output for jifens

6、et(handles.b_edit,String,0);set(handles.a_edit,String,1);handles.output = hObject;(2)运用函数quad8 求函数在不同上下限内的定积分,其中a,b通过编辑文本框输入function jifen_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to jifen_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB

7、% handles structure with handles and user data (see GUIDATA)a=str2num(get(handles.a_edit,String);b=str2num(get(handles.b_edit,String);dx=0.01;x=a:dx:b;y = sin(x).2;ff=inline(sin(x).2,x);q8_ax=quad8(ff,a,b);set(handles.jifen_text,String,num2str(q8_ax);(3)在坐标轴上画出函数图形plot(x,y,r);legend(f(x),3);title(si

8、n(x).2,Fontsize,10,FontWeight,bold);(4)赋予“保存”键保存坐标轴上图像的功能,并且图像可以保存为jpg和bmp的格式function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDA

9、TA)new_f_handle=figure(visible,off);new_axes=copyobj(handles.axes1,new_f_handle); %axes1是GUI界面绘图的坐标系set(new_axes,units,default,position,default);filename,pathname fileindex=uiputfile(*.jpg;*.bmp,save picture as);if filename returnelse file=strcat(pathname,filename); switch fileindex %根据不同的选择保存为不同的类型

10、 case 1 print(new_f_handle,-djpeg,file); case 2 print(new_f_handle,-dbmp,file); endenddelete(new_f_handle);(4)赋予菜单栏中“积分”,“退出”功能退出:function close_menu_Callback(hObject, eventdata, handles)Close积分:function jifen_menu_Callback(hObject, eventdata, handles)jifen_pushbutton_Callback(hObject, eventdata, ha

11、ndles)四、结论及分析(1)主界面图4主界面(2)输入a,b,运行结果图5试运行(3)运用图像保存功能图6图像保存保存结果:图7保存的图像五、设计体会通过这次课程设计,我进一步了解MATLAB的程序设计过程,比较深层次地认识可视化图形用户界面设计的方法以及好处,并且复习了之前学习的MATLAB基础知识,虽说此次实训对我的难度较大,但也是一次很好的锻炼机会参考文献:1陈垚光,毛涛涛,王正林,王玲编著.精通MATLAB GUI.北京:电子工业出版社,2008.2.程序清单:function varargout = jifen(varargin)% JIFEN M-file for jifen.

12、fig% JIFEN, by itself, creates a new JIFEN or raises the existing% singleton*.% H = JIFEN returns the handle to a new JIFEN or the handle to% the existing singleton*.% JIFEN(CALLBACK,hObject,eventData,handles,.) calls the local% function named CALLBACK in JIFEN.M with the given input arguments.% JIF

13、EN(Property,Value,.) creates a new JIFEN or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before jifen_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to jifen

14、_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 help jifen% Last Modified by GUIDE v2.5 02-Jun-2011

15、 16:17:04% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, jifen_OpeningFcn, . gui_OutputFcn, jifen_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback

16、= 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 jifen is made visible.function jifen_OpeningFcn(hObject, eventdata, handles, varargin)% This function h

17、as 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 jifen (see VARARGIN)% Choose default command line output for jifenset(handles.

18、a_edit,String,0);set(handles.b_edit,String,1);handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes jifen wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout = jifen_Ou

19、tputFcn(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

20、 structurevarargout1 = handles.output;% - Executes on button press in jifen_pushbutton.function jifen_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to jifen_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and

21、user data (see GUIDATA)a=str2num(get(handles.a_edit,String);b=str2num(get(handles.b_edit,String);dx=0.01;x=a:dx:b;y = sin(x).2;ff=inline(sin(x).2,x);q8_ax=quad8(ff,a,b);set(handles.jifen_text,String,num2str(q8_ax);plot(x,y,r);legend(f(x),3);title(sin(x)2,Fontsize,10,FontWeight,bold);% - Executes on

22、button press in save_pushbutton.function save_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to save_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)new_f_handle=figure(visible,off);n

23、ew_axes=copyobj(handles.axes1,new_f_handle); %axes1是GUI界面绘图的坐标系set(new_axes,units,default,position,default);filename,pathname fileindex=uiputfile(*.jpg;*.bmp,save picture as);if filename returnelse file=strcat(pathname,filename); switch fileindex %根据不同的选择保存为不同的类型 case 1 print(new_f_handle,-djpeg,fil

24、e); case 2 print(new_f_handle,-dbmp,file); endenddelete(new_f_handle);% - Executes on button press in close_pushbutton.function close_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to close_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% han

25、dles structure with handles and user data (see GUIDATA)closefunction a_edit_Callback(hObject, eventdata, handles)% hObject handle to a_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,Str

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

27、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

28、dColor);endfunction b_edit_Callback(hObject, eventdata, handles)% hObject handle to b_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 b_edit as text% str2doub

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

30、- 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 jifen_menu_Callback(hObject, eventdata, handles)% hObject handle to jifen_menu (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure

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

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