public void Derivation(DataTable ddd, ref DataTable result, bool tt, int K)//平滑并求导,tt为真则是对土壤库求导,否则是对样本库求导,K为放大倍数 { DataTable temp = new DataTable(); Smooth sth = new Smooth(); sth.PlotStore(ref ddd, temp); if (tt) { for (int i = 1; i < T /*ddd.Rows.Count*/; i++) { for (int j = 8; j < temp.Columns.Count; j++) { //计算曲线各个位置上的一阶导数(用差分代替微分) result.Rows[i][j] = K * (Convert.ToDouble(temp.Rows[i][j]) - Convert.ToDouble(temp.Rows[i][j - 1])); } result.Rows[i][7] = 0;//单独给第一个点赋值 } } else { for (int i = 0; i < ddd.Rows.Count; i++) { for (int j = 1; j < temp.Columns.Count; j++) { //计算曲线各个位置上的一阶导数(用差分代替微分并放大) result.Rows[i][j] = K * ((Convert.ToDouble(temp.Rows[i][j]) - Convert.ToDouble(temp.Rows[i][j - 1]))); } result.Rows[i][0] = 0;//单独给第一个点赋值 } } }
public void CalExample() { Derivation(Example, ref ExampleAfter1, false, 100); DataTable temp = new DataTable(); Smooth sth = new Smooth(); sth.PlotStore(ref ExampleAfter1, temp);; Derivation(ExampleAfter1, ref ExampleAfter2, true, 10); FindPeak(ExampleAfter2, ref temp, pexamplecharacter, false); }
public void CalRaw() { Derivation(Raw, ref RawAfter1, true, 100); DataTable temp = new DataTable(); Smooth sth = new Smooth(); sth.PlotStore(ref RawAfter1, temp);; Derivation(RawAfter1, ref RawAfter2, true, 10); FindPeak(RawAfter2, ref temp, pRawcharacter, true); }