版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、題目:利用插值實現(xiàn)數(shù)據(jù)的插值和分段三次小組成員:王曉波(1蔡明宇()一、程序?qū)崿F(xiàn)意義:一般的,從各種試驗得來的數(shù)據(jù)總有一定的數(shù)量,而利用插值技術能夠從有限的數(shù)據(jù)中獲取整體的狀態(tài)。而Hermite插值不僅保證了插值函數(shù)與原函數(shù)在給定數(shù)據(jù)點處得擬合,同時保證了在相應點處導數(shù)的相同,從而在很大程度上保證了曲線的“光滑性”。因此,通過Matlab實現(xiàn)Hermite插值具有很普遍的意義。二、實現(xiàn)過程:1、Hermite插值由于并不是所有的Matlab版本都提供現(xiàn)有的Hermite插值函數(shù)包,故我們首先編寫了實現(xiàn)給定五個觀測點的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的導數(shù)的維數(shù)不相等);return;endelsedisp(x和y的維數(shù)不相等!);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);其中為給定點橫坐標數(shù)組,為給定點縱
3、坐標數(shù)組,為原函數(shù)在給定點處的導數(shù)數(shù)組。測試證明該程序可以實現(xiàn),例如輸入如下數(shù)組: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);運行結(jié)果如下: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函數(shù)實現(xiàn)相應函數(shù)的窗口化,/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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年綠色環(huán)保食材配送餐飲服務協(xié)議3篇
- 辦公空間照明系統(tǒng)升級合同樣本
- 地熱資源招投標投訴處理措施
- 航空航天計量變更準則
- 冷庫安裝合同化妝品研究
- 低碳環(huán)保住宅的二手房買賣合同
- 水利工程保溫施工服務協(xié)議
- 企業(yè)員工商標提案管理辦法
- 玩具制造企業(yè)協(xié)議休假管理辦法
- 預付賬款審核風險控制的關鍵
- 塑料污染與環(huán)境保護
- 2024年鍋爐運行值班員(中級)技能鑒定理論考試題庫(含答案)
- 福建省泉州市2023-2024學年高一上學期期末質(zhì)檢英語試題(解析版)
- 中華人民共和國民法典(總則)培訓課件
- 蘇教版(2024新版)七年級上冊生物期末模擬試卷 3套(含答案)
- 《項目管理》完整課件
- IB課程-PYP小學項目省公開課獲獎課件說課比賽一等獎課件
- 上市央國企數(shù)智化進程中人才就業(yè)趨勢
- 2024-2030年中國苯胺行業(yè)現(xiàn)狀動態(tài)與需求前景展望報告
- 英雄之旅思維模型
- 釘釘數(shù)字化管理師中級題庫
評論
0/150
提交評論