資源簡介
可以最小二乘法擬合任意次數的曲線,繪制了原始折線和擬合曲線的對比圖,有現成代碼可供引用
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
namespace?NH//使用時,須修改為新項目的namespace
{
????class?ecf
????{
????????//擬合代碼,引自星星分享的新浪博客,致謝
????????//作者不能保證此代碼的精確性,但已檢驗過無明顯誤差,無嚴重錯誤
????????///
????????///用最小二乘法擬合二元多次曲線
????????///
????????///已知點的x坐標集合
????????///已知點的y坐標集合
????????///已知點的個數
????????///方程的最高次數
????????public?static?double[]?MultiLine(double[]?arrX?double[]?arrY?int?length?int?dimension)//二元多次線性方程擬合曲線
????????{
????????????int?n?=?dimension?+?1;??????????????????//dimension次方程需要求?dimension+1個?系數
????????????double[]?Guass?=?new?double[n?n?+?1];??????//高斯矩陣?例如:y=a0+a1*x+a2*x*x
????????????for?(int?i?=?0;?i?????????????{
????????????????int?j;
????????????????for?(j?=?0;?j?????????????????{
????????????????????Guass[i?j]?=?SumArr(arrX?j?+?i?length);
?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????11264??2016-04-08?22:15??NH\NH\bin\Debug\NH.exe
?????文件??????32256??2016-04-08?22:15??NH\NH\bin\Debug\NH.pdb
?????文件??????11600??2016-04-08?22:16??NH\NH\bin\Debug\NH.vshost.exe
?????文件????????490??2010-03-17?22:39??NH\NH\bin\Debug\NH.vshost.exe.manifest
?????文件???????4265??2016-04-08?22:15??NH\NH\ecf.cs
?????文件???????2035??2016-04-08?22:11??NH\NH\Form1.cs
?????文件???????2813??2016-04-08?22:06??NH\NH\Form1.Designer.cs
?????文件???????5817??2016-04-08?22:06??NH\NH\Form1.resx
?????文件???????3697??2016-04-08?22:06??NH\NH\NH.csproj
?????文件????????483??2016-04-07?21:29??NH\NH\Program.cs
?????文件???????1354??2016-04-07?21:29??NH\NH\Properties\AssemblyInfo.cs
?????文件???????2855??2016-04-07?21:29??NH\NH\Properties\Resources.Designer.cs
?????文件???????5612??2016-04-07?21:29??NH\NH\Properties\Resources.resx
?????文件???????1088??2016-04-07?21:29??NH\NH\Properties\Settings.Designer.cs
?????文件????????249??2016-04-07?21:29??NH\NH\Properties\Settings.settings
?????文件????????848??2016-04-07?21:29??NH\NH.sln
????..A..H.?????20992??2016-04-08?22:16??NH\NH.suo
?????目錄??????????0??2016-04-08?22:08??NH\NH\bin\Debug
?????目錄??????????0??2016-04-07?21:29??NH\NH\bin
?????目錄??????????0??2016-04-08?22:16??NH\NH\obj
?????目錄??????????0??2016-04-07?21:29??NH\NH\Properties
?????目錄??????????0??2016-04-08?22:06??NH\NH
?????目錄??????????0??2016-04-07?21:29??NH
-----------?---------??----------?-----??----
???????????????107718????????????????????23
評論
共有 條評論