|
楼主 |
发表于 2008-6-29 17:44
|
显示全部楼层
回复 2楼 的帖子
消趋程序
fid=fopen('1.txt','r')
fs=1024
m1=1
x=fscanf(fid,'%f',inf)
sdatus=fclose(fid)
n=length(x)
t=(0:1/fs:(n-1)/fs)'
a1=polyfit(t,x,m1)
c1=polyval(a1,t)
y1=x-c1
plot(t,x,'r')
grid on
hold on
plot(t,y1,'b')
fid=fopen('m1xqhx1.txt','w')
for k=1:n
fprintf(fid,'%f\n',y1(k))
end
sdatus=fclose(fid)
求均值方差程序
fid1=fopen('1.txt','r')
fid2=fopen('m1xqhx1.txt','r')
x1=fscanf(fid1,'%f',inf)
x2=fscanf(fid2,'%f',inf)
v1=var(x1)
v2=var(x2)
m1=mean(x1)
m2=mean(x2)
sdatus=fclose(fid1)
sdatus=fclose(fid2)
有问题吗? |
|