版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、题目:利用插值实现数据的插值和分段三次小组成员:王晓波(1蔡明宇()一、程序实现意义:一般的,从各种试验得来的数据总有一定的数量,而利用插值技术能够从有限的数据中获取整体的状态。而Hermite插值不仅保证了插值函数与原函数在给定数据点处得拟合,同时保证了在相应点处导数的相同,从而在很大程度上保证了曲线的“光滑性”。因此,通过Matlab实现Hermite插值具有很普遍的意义。二、实现过程:1、Hermite插值由于并不是所有的Matlab版本都提供现有的Hermite插值函数包,故我们首先编写了实现给定五个观测点的Hermite插值的M程序,代码如下:functionf,f0=Hermite
2、1(x,y,y_1)symst;f=0.0;if(length(x)=length(y)if(length(y)=length(y_1)n=length(x);elsedisp(y和y的导数的维数不相等);return;endelsedisp(x和y的维数不相等!);return;endfori=1:nh=1.0;a=0.0;forj=1:nif(j=i)h=h*(t-x(j)人2/(x(i)-x(j)人2);a=a+1/(x(i)-x(j);endendf=f+h*(x(i)-t)*(2*a*y(i)-y_1(i)+y(i);endf0=subs(f,t);其中为给定点横坐标数组,为给定点纵
3、坐标数组,为原函数在给定点处的导数数组。测试证明该程序可以实现,例如输入如下数组:x=1:0.2:1.8;y_1=0.50.45640.42260.39530.3727;y=11.09541.18321.26491.3416;f,f0=Hermite1(x,y,y_1);运行结果如下:f=TOC o 1-5 h z(390625*(337232823972231*t)/35184372088832-114418258618928321/10995116277760000)*(t-1)人2*(t-7/5)人2*(t-8/5)人2*(t-9/5)人2)/36-(390625*(t-1)A2*(t-
4、6/5)A2*(t-7/5)A2*(t-9/5)A2*(2855713758717179*t)/281474976710656-384779664999124623/21990232555520000)/36+(390625*(64*t)/3-61/3)*(t-6/5)A2*(t-7/5)A2*(t-8/5)A2*(t-9/5)A2)/576+(390625*(7612884810106783*t)/18014398509481984+6660373488918492043/11258999068426240000)*(t-1)A2*(t-6/5)A2*(t-8/5)A2*(t-9/5)A2)
5、/16-(390625*(7762319875242775*t)/281474976710656-8968626627620006931/175921860444160000)*(t-1)A2*(t-6/5)A2*(t-7/5)A2*(t-8/5)A2)/576f0=1.1000利用matlab绘制图像:FigureFileEditViewInsertToolsDtEktopWindowHelpH3口匡1口1.41.351.32、程序的窗口化:利用Matlab:GUI代码如下:1.25提供的GUIDE工具以及callback函数实现相应函数的窗口化,/functionvararg?utUNTI
6、TLEDM-fileUNTITLED,bysingleton*.=untitled(varargin)”foruntitled.fig/itself,createsanewUNTITLEDorraisestheexistingH=UNTITLED_*returnsthehandleanewUNTITLEDorthehandletotheexisting1.05singleton*.UNTITLED(CALLBACK,local,hObject,eventData,handles,.)callsthe1.41111functionnamedCALLBACKi1n1UNTITLED.MWithth
7、egivenTinputarguments.%UNTITLED(Property,Valuecreatesanewun丄丄丄ledorraisestheexistingsingleton*.Startingfromtheleft,propertyvaluepairsareappliedtotheGUIbeforeuntitled_OpeningFcngetscalled.Anunrecognizedpropertynameorinvalidvaluemakespropertyapplication%stop.Allinputsarepassedtountitled_OpeningFcnviav
8、arargin.%*SeeGUIOptionsonGUIDEsToolsmenu.ChooseGUIallowsonlyoneinstancetorun(singleton)%Seealso:GUIDE,GUIDATA,GUIHANDLES%Edittheabovetexttomodifytheresponsetohelpuntitled%LastModifiedbyGUIDEv2.515-Sep-201122:24:48ifnargoutBegininitializationcode-DOgui_Singleton=1;gui_StateNOTEDIT=struct(gui_Name,gui
9、_Singleton,gui_OpeningFcn,gui_OutputFcn,gui_LayoutFcn,gui_Callback,&ischar(varargin1)mfilename,.gui_Singleton,.untitled_OpeningFcn,.untitled_OutputFcn,.,.);ifnargingui_State.gui_Callback=str2func(varargin1);endvarargout1:nargout=gui_mainfcn(gui_State,varargin:);elsegui_mainfcn(gui_State,varargin:);e
10、nd%Endinitializationcode-DONOTEDIT%-Executesjustbeforeuntitledismadevisible.functionuntitled_OpeningFcn(hObject,eventdata,handles,varargin)%Thisfunctionhasnooutputargs,seeOutputFcn.%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(see
11、GUIDATA)%varargincommandlineargumentstountitled(seeVARARGIN)%Choosedefaultcommandlineoutputforuntitledhandles.output=hObject;%Updatehandlesstructureguidata(hObject,handles);%UIWAITmakesuntitledwaitforuserresponse(seeUIRESUME)%uiwait(handles.figure1);%-Outputsfromthisfunctionarereturnedtothecommandli
12、ne.functionvarargout=untitled_OutputFcn(hObject,eventdata,handles)%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Getdefaultcommandlineoutputfromhandlesstructurevar
13、argout1=handles.output;functionedit1_Callback(hObject,eventdata,handles)%hObjecthandletoedit1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,String)returnscontentsofedit1astext%str2double(get(hObject,String)returnsc
14、ontentsofedit1asadoubleguidata(hObject,handles);%-Executesduringobjectcreation,aftersettingallproperties.functionedit1_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%
15、Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);endfunctionedit2_Callback(hObject,eventdata,handles)%hObjecthandletoedit2(seeGCBO)%eventdatareserved-tobedefi
16、nedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,String)returnscontentsofedit2astext%str2double(get(hObject,String)returnscontentsofedit2asadoubleguidata(hObject,handles);%-Executesduringobjectcreation,aftersettingallproperties.functionedit2_CreateFcn(
17、hObject,eventdata,handles)%hObjecthandletoedit2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&isequal(get(hObject,BackgroundColor),get(0,defau
18、ltUicontrolBackgroundColor)set(hObject,BackgroundColor,white);endfunctionedit3_Callback(hObject,eventdata,handles)%hObjecthandletoedit3(seeGCBO)%eventdatareservedtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,String)returnscontentsofedit3aste
19、xt%str2double(get(hObject,String)returnscontentsofedit3asadoubleguidata(hObject,handles);%-Executesduringobjectcreation,aftersettingallproperties.functionedit3_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handle
20、snotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);endfunctionedit4_Callback(hObject,eventdata,handles)%hObjecthandleto
21、edit4(seeGCBO)%eventdatareservedtobedefinedinafutureversionofMATLAB%eventdatareservedtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,String)returnscontentsofedit4astext%str2double(get(hObject,
22、String)returnscontentsofedit4asadouble%-Executesduringobjectcreation,aftersettingallproperties.functionedit4_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit4(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editc
23、ontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);end%-Executesonbuttonpressinpushbutton1.functionpushbutton1_Callback(hObject,eventdata,handles)%hObjecthandletopushbutt
24、on1(seeGCBO)x=str2num(get(handles.edit1,string);y=str2num(get(handles.edit2,string);y_1=str2num(get(handles.edit3,string);x0=str2num(get(handles.edit5,string);symst;f=0.0;if(length(x)=length(y)if(length(y)=length(y_1)n=length(x);elsedisp(yfyp亘卩吻总亘(总?2工卩总);return;endelsedisp(xfy卩亘f总卩总:);return;endfor
25、i=1:nh=1.0;a=0.0;forj=1:nif(j=i)h=h*(t-x(j)八2/(x(i)-x(j)八2);a=a+1/(x(i)-x(j);endendf=f+h*(x(i)-t)*(2*a*y(i)-y_1(i)+y(i);endf0=subs(f,t,x0);plot(handles.poltarea,x,y,*);functionedit5_Callback(hObject,eventdata,handles)%hObjecthandletoedit5(seeGCBO)%eventdatareservedtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,String)returnscontentsofedit5astext%str2double(get(hObject,String)returnscontentsofedit
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 淮阴师范学院《政治学原理》2021-2022学年第一学期期末试卷
- 淮阴工学院《天然药物绿色制备技术》2022-2023学年第一学期期末试卷
- DB4420+T+55-2024《龙舟竞渡文化体验服务指南》
- DB2310-T 149-2024铃兰分株育苗技术规程
- 有关招聘计划锦集五篇
- 专业领域学习技巧探讨座谈会考核试卷
- 宠物行为问题诊断与矫正考核试卷
- 农药制造的质量保障与质量控制考核试卷
- 木材采运管理中的协同与协调机制考核试卷
- 弹射玩具企业品牌竞争力提升考核试卷
- 3.1列代数式表示数量关系(第2课时 列代数式) 课件 2024-2025学年七年级数学上册 (人教版2024)
- 土壤污染重点监管单位隐患排查技术指南第4部分:医药制造业
- 变压器二手买卖合同范本2024年
- 2024年全国高考Ⅰ卷英语试题及答案
- 个人不再信访承诺书
- 2024年山西航空产业集团限公司校园招聘(高频重点提升专题训练)共500题附带答案详解
- NB-T 10436-2020 电动汽车快速更换电池箱冷却接口通.用技术要求
- 毓璜顶医院出院记录
- 人教版高中地理选择性必修1第一章地球的运动单元检测含答案
- xf124-2013正压式消防空气呼吸器标准
- 湖北省2024年中考英语真题【附真题答案】
评论
0/150
提交评论