Using polifit in matlab
显示 更早的评论
Hi,
I'm processing some data collected of charges and discharges curves of a battery. To do so, I'm fitting the data to a polynomial using polifit. what I'm doing is the following:
t=time(line,colomn);
V=volt(line,colomn);
sz=size(t,1);
l=150;
n=3;
tab=[];
%charge
for k1=(1+l/2):sz-l/2
x=t((k1-l/2):(k1+l/2),1);
y=V((k1-l/2):(k1+l/2),1);
poly=polyfit(x,y,n);
yf=polyval(pply,t(k1,1));
tab=[tab;t(k1,1) yf];
%But it takes a lot of time doing it. It exist any other way to do the same thing in less time?
%I think that part of the problem come from doing vertcat of each value.
thank you
采纳的回答
更多回答(1 个)
Image Analyst
2017-6-2
2 个投票
How much data do you have? Billions of elements? Otherwise it should be really fast. Since the (badly named) l is 150, it looks like the fits are done over only a minuscule 150 points, so that should be blazingly fast to do just a single fit.
It looks like you're trying to fit lots of polynomials in a window sliding along your data. If so, that's basically a Savitzky-Golay filter and can be done efficiently using the function sgolayfilt() in the Signal Processing Toolbox.
类别
在 帮助中心 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!