0

I have a csv file which contains data like below:[1st row is header]

Element,State,Time
Water,Solid,1
Water,Solid,2
Water,Solid,3
Water,Solid,4
Water,Solid,5
Water,Solid,2
Water,Solid,3
Water,Solid,4
Water,Solid,5
Water,Solid,6
Water,Solid,7
Water,Solid,8
Water,Solid,7
Water,Solid,6
Water,Solid,5
Water,Solid,4
Water,Solid,3

The similar pattern is repeated for State: "Solid" replaced with Liquid and Gas. And moreover the Element "Water" can be replaced by some other element too. Time as Integer's are in seconds (to simplify) but can be any real number. Additionally there might by some comment line starting with # in between the file.

Problem Statement: I want to eliminate the first dip in Time values and smooth out using some quadratic or cubic or polynomial interpolation [please notice the first change from 5->2 --->8. I want to replace these numbers to intermediate values giving a gradual/smooth increase from 5--->8].

And I wish this to be done for all the combinations of Elements and States.

Is this possible through some sort of coding in Matlab etc ?

Any Pointers will be helpful !!

Thanks in advance :)

4

2 回答 2

1

您在这里有很多选择,这实际上取决于您的数据的性质,但我会从一个简单的移动平均 (MA) 过滤器开始(它将每个数据点替换为相邻数据点的平均值),然后看看这需要我。它很容易实现,在一些样本数据上微调 MA-span 几次通常就足够了。

http://www.mathworks.se/help/curvefit/smoothing-data.html

除非我真的需要压缩它,否则我不会尝试将多项式拟合到整个数据集,(但要这样做,您可以使用该polyfit函数)。

于 2013-03-11T21:45:52.840 回答
1

您可以使用该interp1功能进行一维插值。语法是

yi = interp1(x,y,xi,method)

哪里x是你的原始坐标,y你的原始值,xi是你想要插值的坐标,是yi插值。method可以是'spline'(三次样条插值)、'pchip'(分段 Hermite)、'cubic'(三次多项式)等(详见文档)。

于 2013-03-11T20:36:55.293 回答