|
消趋势项
这里有个书上的通用例子
最小二乘去趋势项
fni=input('消除多项式趋势项-输入文件名:','s')
fidin=fopen(fni,'r')
Fs=1024
%实际振动中常采用m=1~3来去趋势项
m=2
fidout=fopen('xqsx2.txt','w')
x=fscanf(fidin,'%f',inf)
status=fclose(fidin)
%取数据长度
n=length(x)
t=(0:1/Fs:(n-1)/Fs)'
%求趋势项多项式待定系数向量
a=polyfit(t,x,m)
y=x-polyval(a,t)
subplot(211)
plot(t,x)
xlabel('t/s')
ylabel('加速度/g')
title('消趋势项前')
grid on
subplot(212)
plot(t,y)
xlabel('t/s')
ylabel('加速度/g')
title('消趋势项后') |
评分
-
1
查看全部评分
-
|