• 大小: 3KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-01-05
  • 语言: Matlab
  • 标签: matlab  txt  滤波  

资源简介

matlab读取txt数据,然后然后限幅+递推平均滤波,只需改变文件路径就可用

资源截图

代码片段和文件信息


data=textread(‘D:\airboard hardware\超声模块\串口接收数据\测试.txt‘‘%s‘);
data2=hex2dec(data);
count=0;
tp=1;
num=1;
cc=4;
time=1;
%plot(data2);
d=length(data2);
a=1;
b=1;
data3=1:1:d/3;
data4=1:1:d/3;
while a    if (data2(a)==253)
    data3(b)=data2(a+2)*256+data2(a+1);a=a+3;b=b+1;                                                    
    else a=a+1;
    end
end

sum=data3(1);
            for i=1:1:(length(data3)-1)
                        if  ((data3(i+1)-data3(i))>3||(data3(i)-data3(i+1))>3) %限幅滤波
                                count=count+1;
                                if count==10
                                    count=0;
                                    tp=0;
                                    data3(i+1)=data3(i+1);
                                el

评论

共有 条评论