求教各位大神,怎么用c++ builder 2010 实现 一组数据的一维线性插值?

huxuedong12345 2014-09-03 12:43:02
最好能写出代码,各位帮帮忙呀
...全文
293 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
toobug19 2014-09-06
  • 打赏
  • 举报
回复
实现的代码贴不上了。另外,你可以使用GNU下的GLS数学库进行计算。或者用matlab进行计算。
toobug19 2014-09-06
  • 打赏
  • 举报
回复
[code=c][//--------------------------------------------------------------------------- #ifndef linera_interpolationH #define linera_interpolationH //--------------------------------------------------------------------------- #include <vector> typedef struct{ double dbl_x; double dbl_y; }DataPoint; class LinearInter { public: /* 传递原始数据数组 */ void InputData(const DataPoint* pDataPoint, unsigned int n); /* 传递单一数据对象 */ void InputData(const DataPoint& dataPoint); /* 删除单一数据对象 */ bool DeleteData(const DataPoint& dataPoint); bool DeleteData(unsigned n); /* 给定x值,计算出y值 */ const DataPoint OutputData(const double x) const; DataPoint* OutputData(const double* x_array, unsigned int n, DataPoint* pDataPoint) const; /* 清空原始数据成员 */ void ClearData(); /* 返回当前原始数据大小 */ unsigned int GetRowDataSize() const; /* 返回当前原始数据,数组可变 */ DataPoint* GetRowData(unsigned int n, DataPoint* pDataPoint) const; public: LinearInter(); ~LinearInter(); private: void Interpolate(); // 计算插值 private: std::vector<DataPoint> m_DataList; // 存储原始数据 double m_Slope; // double m_Constant; // y = k*x + c }; #endif/code]
huxuedong12345 2014-09-03
  • 打赏
  • 举报
回复
如果数据太多用最小二乘法就太麻烦了
toobug19 2014-09-03
  • 打赏
  • 举报
回复
先线性拟合,一般用最小二乘法,算出函数,再代入你要的插值不就计算出来了吗?

13,824

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧