⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tan9.asv

📁 3D加速信号处理
💻 ASV
📖 第 1 页 / 共 2 页
字号:
FileName='running22.txt';
MK=importdata(FileName);      % 将生成的MKMATLAB.txt文件导入工作空间,变量名为MK,实际上它不显示出来
%Y=0:300/(size(MK,1)-1):300;

MK1=MK(:,1);MK2=MK(:,2);MK3=MK(:,3);

%坐标选取
MK1min=min(MK1);MK2min=min(MK2);MK3min=min(MK3);
MK1max=max(MK1);MK2max=max(MK2);MK3max=max(MK3);
Xmin=0;
Xmax=(round(size(MK,1)/500)+1)*500;
Y1min=round(MK1min/50)*50;
Y2min=round(MK2min/50)*50;
Y3min=round(MK3min/50)*50;
Y1max=(round(MK1max/50)+1)*50;
Y2max=(round(MK2max/50)+1)*50;
Y3max=(round(MK3max/50)+1)*50;

%滤波器的设计
b1=[0.2 0.2 0.2 0.2 0.2];  %均值
b2=[0.1 0.1 0.6 0.1 0.1];  %中值
b3=[0.073 0.118 0.618 0.118 0.073];  %中值(黄金分割)
b4=[-0.1 -0.1 1.4 -0.1 -0.1];

b5=1/7*ones(1,7);
b6=[0.08 0.08 0.08 0.52 0.08 0.08 0.08];
b7=[0.019 0.054 0.118 0.618 0.118 0.054 0.019];
b8=[-0.0667 -0.0667 -0.0667 1.4 -0.0667 -0.0667 -0.0667];
%b4 锐化算法
%b5 量化
b=b2;
MK4=filter(b,1,MK1);MK4(1:5)=mean(MK1(1:5));
MK4=uint8(MK4);
MK5=filter(b,1,MK2);MK5(1:5)=mean(MK2(1:5));
MK5=uint8(MK5);
MK6=filter(b,1,MK3);MK6(1:5)=MK3(1:5);
MK6=uint8(MK6);

%作图
h0=figure('toolbar','none',...
    'position',[50 50 900 650],...
    'name','3D加速信号的预处理');
subplot(811);
plot(MK1,'r');grid on;
axis([Xmin Xmax Y1min Y1max]);
subplot(812);
plot(MK4,'r');grid on;
axis([Xmin Xmax Y1min Y1max]);

subplot(813);
plot(MK2,'b');grid on;
axis([Xmin Xmax Y1min Y1max]);
subplot(814);
plot(MK5,'b');grid on;
axis([Xmin Xmax Y2min Y2max]);

subplot(815);
plot(MK(:,3),'m');grid on;
axis([Xmin Xmax Y3min Y3max]);
subplot(816);
plot(MK6,'m');grid on;
axis([Xmin Xmax Y3min Y3max]);

%Button的设计
%h=get(gca,'xlim');
%k=get(gca,'ylim');
h=[2000 3000];
k=[50 250];
zbChange=1;
e1=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(h(1))),...
    'horizontalalignment','right',...
    'position',[270 120 80 20]);
t1=uicontrol('parent',h0,...    %to get xmin
    'style','text',...
    'string','X轴最小值',...
    'position',[270 145 80 20]);
e2=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(h(2))),...
    'horizontalalignment','right',...
    'position',[270 60 80 20]);
t2=uicontrol('parent',h0,...   %to get xmin
    'style','text',...
    'string','X轴最大值',...
    'position',[270 85 80 20]);
e3=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(k(1))),...
    'horizontalalignment','right',...
    'position',[370 120 80 20]);
t3=uicontrol('parent',h0,...   %to get ymin
    'style','text',...
    'string','Y轴最小值',...
    'position',[370 145 80 20]);
e4=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(k(2))),...
    'horizontalalignment','right',...
    'position',[370 60 80 20]);
t4=uicontrol('parent',h0,...   %to get ymax
    'style','text',...
    'string','Y轴最大值',...
    'position',[370 85 80 20]);
p1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','设置',...
    'position',[270 10 50 30],...
    'callback',[...
        'a=str2num(get(e1,''string''));,',...
        'b=str2num(get(e2,''string''));,',...
        'c=str2num(get(e3,''string''));,',...
        'd=str2num(get(e4,''string''));,',...     
        'subplot(8,1,2*zbChange-1),',...
        'axis([a b c d]),',...
        'subplot(8,1,2*zbChange),',...
        'axis([a b c d]),',...        
        'drawnow']);
p2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','还原',...
    'position',[340 10 50 30],...
    'callback',[...
        'subplot(811);',...
        'axis([Xmin Xmax Y1min Y1max]);',...
        'subplot(812);',...
        'axis([Xmin Xmax Y1min Y1max]);',...
        'subplot(813);',...
        'axis([Xmin Xmax Y2min Y2max]);',...
        'subplot(814);',...
        'axis([Xmin Xmax Y2min Y2max]);',...
        'subplot(815);',...
        'axis([Xmin Xmax Y3min Y3max]);',...
        'subplot(816);',...
        'axis([Xmin Xmax Y3min Y3max]);'       
        ]);
p3=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','关闭',...
    'position',[410 10 50 30],...
    'callback','close');

s1=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[100 110 72.75 16.5],...
    'string','坐标纵横比',...
    'style','text',...
    'tag','s1');
r1=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[100 90 72.75 16.5],...
    'string','第一组信号',...
    'style','radiobutton',...
    'tag','r1',...
    'value',1,...
    'callback',[...  
        'set(r1,''value'',1);,',...
        'set(r2,''value'',0);,',...
        'set(r3,''value'',0);,',...
        'zbChange=1;']);
r2=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[100 65 72.75 16.5],...
    'string','第二组信号',...
    'style','radiobutton',...
    'tag','r2',...
    'value',0,...
    'callback',[... 
        'set(r1,''value'',0);,',...
        'set(r2,''value'',1);,',...
        'set(r3,''value'',0);,',...
        'zbChange=2;']);
r3=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[100 40 72.75 16.5],...
    'string','第三组信号',...
    'style','radiobutton',...
    'tag','r3',...
    'value',0,...
    'callback',[...  
        'set(r1,''value'',0);,',...
        'set(r2,''value'',0);,',...
        'set(r3,''value'',1);,',...
        'zbChange=3;']);
    
    
u1=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[430 100 72.75 16.5],...
    'string','均值滤波',...
    'style','radiobutton',...
    'tag','u1',...
    'value',0,...
    'callback',[...  
        'set(u1,''value'',1);,',...
        'set(u2,''value'',0);,',...
        'set(u3,''value'',0);,',...
        'set(u4,''value'',0);,',...
        'set(u5,''value'',0);,',...
        'set(u6,''value'',0);,',...
        'set(u7,''value'',0);,',...
        'set(u8,''value'',0);,',...
        'set(u9,''value'',0);,',...
        'set(u10,''value'',0);,',...
        'b=b1;',...
        'MK4=filter(b,1,MK1);MK4(1:5)=MK1(1:5);',...
        'MK4=uint8(MK4);',...
        'MK5=filter(b,1,MK2);MK5(1:5)=MK2(1:5);',...
        'MK5=uint8(MK5);',...
        'MK6=filter(b,1,MK3);MK6(1:5)=MK3(1:5);',...
        'MK6=uint8(MK6);',...
        'subplot(811);',...
        'plot(MK1,''r'');',...
        'axis([Xmin Xmax Y1min Y1max]);',...
        'subplot(812);',...
        'plot(MK4,''r'');',...
        'axis([Xmin Xmax Y1min Y1max]);',...
        'subplot(813);',...
        'plot(MK2,''b'');',...
        'axis([Xmin Xmax Y2min Y2max]);',...
        'subplot(814);',...
        'plot(MK5,''b'');',...
        'axis([Xmin Xmax Y2min Y2max]);',...
        'subplot(815);',...
        'plot(MK3,''m'');',...
        'axis([Xmin Xmax Y3min Y3max]);',...
        'subplot(816);',...
        'plot(MK6,''m'');',...
        'axis([Xmin Xmax Y3min Y3max]);']);
    
u2=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[430 80 72.75 16.5],...
    'string','中值滤波',...
    'style','radiobutton',...
    'tag','u2',...
    'value',1,...
    'callback',[...  
        'set(u1,''value'',0);,',...
        'set(u2,''value'',1);,',...
        'set(u3,''value'',0);,',...
        'set(u4,''value'',0);,',...
        'set(u5,''value'',0);,',...
        'set(u6,''value'',0);,',...
        'set(u7,''value'',0);,',...
        'set(u8,''value'',0);,',...
        'set(u9,''value'',0);,',...
        'set(u10,''value'',0);,',...
        'b=b2;',...
        'MK4=filter(b,1,MK1);MK4(1:5)=MK1(1:5);',...
        'MK4=uint8(MK4);',...
        'MK5=filter(b,1,MK2);MK5(1:5)=MK2(1:5);',...
        'MK5=uint8(MK5);',...
        'MK6=filter(b,1,MK3);MK6(1:5)=MK3(1:5);',...
        'MK6=uint8(MK6);',...
        'subplot(811);',...
        'plot(MK1,''r'');',...
        'axis([Xmin Xmax Y1min Y1max]);',...
        'subplot(812);',...
        'plot(MK4,''r'');',...
        'axis([Xmin Xmax Y1min Y1max]);',...
        'subplot(813);',...
        'plot(MK2,''b'');',...
        'axis([Xmin Xmax Y2min Y2max]);',...
        'subplot(814);',...
        'plot(MK5,''b'');',...
        'axis([Xmin Xmax Y2min Y2max]);',...
        'subplot(815);',...
        'plot(MK3,''m'');',...
        'axis([Xmin Xmax Y3min Y3max]);',...
        'subplot(816);',...
        'plot(MK6,''m'');',...
        'axis([Xmin Xmax Y3min Y3max]);']);
    
u3=uicontrol('parent',h0,...
    'units','points',...
    'backgroundcolor',[0.753 0.753 0.753],...
    'listboxtop',0,...
    'position',[430 60 72.75 16.5],...
    'string','中值滤波2',...
    'style','radiobutton',...
    'tag','u3',...
    'value',0,...
    'callback',[...  
        'set(u1,''value'',0);,',...
        'set(u2,''value'',0);,',...
        'set(u3,''value'',1);,',...
        'set(u4,''value'',0);,',...
        'set(u5,''value'',0);,',...
        'set(u6,''value'',0);,',...
        'set(u7,''value'',0);,',...
        'set(u8,''value'',0);,',...
        'set(u9,''value'',0);,',...
        'set(u10,''value'',0);,',...
        'b=b3;',...
        'MK4=filter(b,1,MK1);MK4(1:5)=MK1(1:5);',...
        'MK4=uint8(MK4);',...
        'MK5=filter(b,1,MK2);MK5(1:5)=MK2(1:5);',...
        'MK5=uint8(MK5);',...
        'MK6=filter(b,1,MK3);MK6(1:5)=MK3(1:5);',...
        'MK6=uint8(MK6);',...
        'subplot(811);',...
        'plot(MK1,''r'');',...
        'axis([Xmin Xmax Y1min Y1max]);',...
        'subplot(812);',...
        'plot(MK4,''r'');',...
        'axis([Xmin Xmax Y1min Y1max]);',...
        'subplot(813);',...
        'plot(MK2,''b'');',...
        'axis([Xmin Xmax Y2min Y2max]);',...
        'subplot(814);',...
        'plot(MK5,''b'');',...
        'axis([Xmin Xmax Y2min Y2max]);',...
        'subplot(815);',...
        'plot(MK3,''m'');',...
        'axis([Xmin Xmax Y3min Y3max]);',...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -