?? convxcorr.txt
字號:
%-----------------------------------------------------------------
% exa011006_conv.m: for example 1.10.6
% to test conv.m
% 計算兩個序列的線性卷積;
%-----------------------------------------------------------------
clear;
N=5;
M=6;
L=N+M-1;
x=[1,2,3,4,5];
h=[6,2,3,6,4,2];
y=conv(x,h);
nx=0:N-1;
nh=0:M-1;
ny=0:L-1;
subplot(231);
stem(nx,x,'.k');xlabel('n');ylabel('x(n)');grid on;
subplot(232);
stem(nh,h,'.k');xlabel('n');ylabel('h(n)');grid on;
subplot(233);
stem(ny,y,'.k');xlabel('n');ylabel('y(n)');grid on;
y
%-----------------------------------------------------------------
% exa011007_xcorr.m: for example 1.10.7 and example 1.8.3
% to test xcorr.m
% 求兩個序列的互相關函數,或一個序列的自相關函數;
%-----------------------------------------------------------------
clear;
N=500;
p1=1;
p2=0.1;
f=1/8;
Mlag=50;
u=randn(1,N);
n=[0:N-1];
s=sin(2*pi*f*n);
% 混有高斯白噪的正弦信號的自相關
u1=u*sqrt(p1);
x1=u1(1:N)+s;
rx1=xcorr(x1,Mlag,'biased');
subplot(221);
plot(x1(1:Mlag));
xlabel('n');
ylabel('x1(n)');grid on;
subplot(223);
plot((-Mlag:Mlag),rx1);grid on;
xlabel('m');ylabel('rx1(m)');
% 高斯白噪功率由原來的p1減少為p2,再觀察混合信號的自相關
u2=u*sqrt(p2);
x2=u2(1:N)+s;
rx2=xcorr(x2,Mlag,'biased');
subplot(222);
plot(x2(1:Mlag));
xlabel('n');ylabel('x2(n)');grid on;
subplot(224);
plot((-Mlag:Mlag),rx2);
grid on;xlabel('m');ylabel('rx2(m)');
cameraman=imread('cameraman.tif');
H=hadamard(256);
%hadamad矩陣
cameraman=double(cameraman)/255;
%數據類型轉換
hcameraman=H*cameraman*H;
%Hadamard變換
hcameraman=hcameraman/256;
subplot(121)
imshow(hcameraman);
title('cameraman圖像的二維離散Hadamard變換');
subplot(122)
ccameraman=dct2(cameraman);
%離散余弦變換
imshow(ccameraman);
title('cameraman圖像的二維離散余弦變換');
load sinsin
% 打開原始圖像
% X中包含圖像信息
init=2055615866; randn('seed',init);
x = X + 18*randn(size(X));
%產生噪聲圖像
% 用 wdencmp函數給圖像除噪
[thr,sorh,keepapp] = ddencmp('den','wv',x);
% 發現缺省值
xd = wdencmp('gbl',x,'sym4',2,thr,sorh,keepapp);
% 使用全局閾值參數除噪圖像
subplot(121)
imshow(x,map)
title('加噪圖像')
subplot(122)
imshow(xd,map)
title('除噪圖像')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -