?? tan4.asv
字號:
MK=importdata('running22.txt'); % 將生成的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]; %中值(黃金分割)
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);
%作圖
h0=figure('toolbar','none',...
'position',[50 50 900 650],...
'name','3D加速信號的預處理');
subplot(811);
plot(MK1,'r');ylabel('Signal 1');grid on;
Ymin=Y1min;Ymax=Y1max;
axis([Xmin Xmax Ymin Ymax]);
subplot(812);
plot(MK4,'r');grid on;
Ymin=Y1min;Ymax=Y1max;
axis([Xmin Xmax Ymin Ymax]);
subplot(813);
plot(MK2,'b');ylabel('Signal 2');grid on;
Ymin=Y2min;Ymax=Y2max;
axis([Xmin Xmax Ymin Ymax]);
subplot(814);
plot(MK5,'b');grid on;
Ymin=Y2min;Ymax=Y2max;
axis([Xmin Xmax Ymin Ymax]);
subplot(815);
plot(MK3,'m');ylabel('Signal 3');grid on;
Ymin=Y3min;Ymax=Y3max;
axis([Xmin Xmax Ymin Ymax]);
subplot(816);
plot(MK6,'m');grid on;
Ymin=Y3min;Ymax=Y3max;
axis([Xmin Xmax Ymin Ymax]);
%Button的設計
h=get(gca,'xlim');
k=get(gca,'ylim');
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',[500 110 72.75 16.5],...
'string','均值濾波',...
'style','radiobutton',...
'tag','r1',...
'value',0,...
'callback',[...
'set(u1,''value'',1);,',...
'set(u2,''value'',0);,',...
'set(u3,''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'');',...
'ylabel(''Signal 1'');',...
'subplot(812);',...
'plot(MK4,''r'');',...
'subplot(813);',...
'plot(MK2,''b'');',...
'ylabel(''Signal 2'');',...
'subplot(814);',...
'plot(MK5,''b'');',...
'subplot(815);',...
'plot(MK3,''m'');',...
'ylabel(''Signal 3'');',...
'subplot(816);',...
'plot(MK6,''m'');']);
u2=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[500 85 72.75 16.5],...
'string','中值濾波',...
'style','radiobutton',...
'tag','u2',...
'value',1,...
'callback',[...
'set(u1,''value'',0);,',...
'set(u2,''value'',1);,',...
'set(u3,''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'');',...
'ylabel(''Signal 1'');',...
'subplot(812);',...
'plot(MK4,''r'');',...
'subplot(813);',...
'plot(MK2,''b'');',...
'ylabel(''Signal 2'');',...
'subplot(814);',...
'plot(MK5,''b'');',...
'subplot(815);',...
'plot(MK3,''m'');',...
'ylabel(''Signal 3'');',...
'subplot(816);',...
'plot(MK6,''m'');']);
u3=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[500 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);,',...
'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'');',...
'ylabel(''Signal 1'');',...
'subplot(812);',...
'plot(MK4,''r'');',...
'subplot(813);',...
'plot(MK2,''b'');',...
'ylabel(''Signal 2'');',...
'subplot(814);',...
'plot(MK5,''b'');',...
'subplot(815);',...
'plot(MK3,''m'');',...
'ylabel(''Signal 3'');',...
'subplot(816);',...
'plot(MK6,''m'');']);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -