用到的性质

上代码:

n = -5:10; x = rand(1,length(n));
k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , [0,pi] axis divided into 101 points.
X = x * (exp(-j*pi/100)) .^ (n'*k); % DTFT of x % folding property
y = fliplr(x); m = -fliplr(n); % signal folding
Y = y * (exp(-j*pi/100)) .^ (m'*k); % DTFT of y magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X);
magY = abs(Y); angY = angle(Y); realY = real(Y); imagY = imag(Y); %verification
Y_check = fliplr(X); % X(-w)
error = max(abs(Y-Y_check)); % Difference figure('NumberTitle', 'off', 'Name', 'x & y sequence')
set(gcf,'Color','white');
subplot(2,1,1); stem(n,x); title('x sequence '); xlabel('n'); ylabel('x(n)'); grid on;
%subplot(2,2,2); stem(n,imag(x)); title('x sequence Imaginary Part'); xlabel('n'); ylabel('Imaginary x(n))'); grid on;
subplot(2,1,2); stem(m,y); title('y sequence '); xlabel('n'); ylabel('y(n)'); grid on;
%subplot(2,2,4); stem(n,imag(y)); title('y sequence Imaginary Part'); xlabel('n'); ylabel('Imaginary y(n))'); grid on; %% --------------------------------------------------------------
%% START X's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'X its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX); grid on; % axis([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X|');
subplot(2,2,3); plot(w/pi, angX/pi); grid on; % axis([-2,2,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realX); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagX); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% --------------------------------------------------------------
%% END X's mag ang real imag
%% -------------------------------------------------------------- %% --------------------------------------------------------------
%% START Y's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Y its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magY); grid on; % axis([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |Y|');
subplot(2,2,3); plot(w/pi, angY/pi); grid on; % axis([-2,2,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realY); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagY); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); %% --------------------------------------------------------------
%% END Y's mag ang real imag
%% -------------------------------------------------------------- %% ----------------------------------------------------------------
%% START Graphical verification
%% ----------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'X Y compare theirs Magnitude and Angle');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX); grid on; %axis([-1,1,0,12]);
xlabel('frequency in \pi units'); ylabel('|X|'); title('Magnitude of X ');
subplot(2,2,2); plot(w/pi,angX/pi); grid on; axis([-1,1,-1,1]);
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); title('Angle of X '); subplot(2,2,3); plot(w/pi,magY); grid on; %axis([-1,1,0,12]);
xlabel('frequency in \pi units'); ylabel('|Y|'); title('Magnitude of Y ');
subplot(2,2,4); plot(w/pi,angY/pi); grid on; axis([-1,1,-1,1]);
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); title('Angle of Y '); %% ----------------------------------------------------------------
%% END Graphical verification
%% ----------------------------------------------------------------

运行结果:

DSP using MATLAB 示例 Example3.11的更多相关文章

  1. DSP using MATLAB 示例Example3.21

    代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*a ...

  2. DSP using MATLAB 示例 Example3.19

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...

  3. DSP using MATLAB示例Example3.18

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...

  4. DSP using MATLAB 示例Example3.23

    代码: % Discrete-time Signal x1(n) : Ts = 0.0002 Ts = 0.0002; n = -25:1:25; nTs = n*Ts; x1 = exp(-1000 ...

  5. DSP using MATLAB示例Example3.16

    代码: b = [0.0181, 0.0543, 0.0543, 0.0181]; % filter coefficient array b a = [1.0000, -1.7600, 1.1829, ...

  6. DSP using MATLAB 示例Example3.8

    代码: x = rand(1,11); n = 0:10; k = 0:500; w = (pi/500)*k; % [0,pi] axis divided into 501 points. X = ...

  7. DSP using MATLAB 示例Example3.7

    上代码: x1 = rand(1,11); x2 = rand(1,11); n = 0:10; alpha = 2; beta = 3; k = 0:500; w = (pi/500)*k; % [ ...

  8. DSP using MATLAB 示例Example3.22

    代码: % Discrete-time Signal x2(n) Ts = 0.001; n = -5:1:5; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nT ...

  9. DSP using MATLAB 示例Example3.17

随机推荐

  1. 用原生DOM 遍历页面节点

    代码丢失,直接上图:

  2. App主界面Tab实现方法

    ViewPager + FragmentPagerAdapter 这里模仿下微信APP界面的实现 国际惯例,先看下效果图:   activity_main.xml 布局文件: <?xml ver ...

  3. 【leetcode】House Robber & House Robber II(middle)

    You are a professional robber planning to rob houses along a street. Each house has a certain amount ...

  4. 【编程题目】设计包含 min 函数的栈

    2.设计包含 min 函数的栈(栈)定义栈的数据结构,要求添加一个 min 函数,能够得到栈的最小元素.要求函数 min.push 以及 pop 的时间复杂度都是 O(1). 我的思路: 用一个额外的 ...

  5. PHP安全编程:过滤用户输入

    如果你能正确可靠地识别和过滤输入,你的工作就基本完成了.最后一步是使用一个命名约定或其它可以帮助你正确和可靠地区分已过滤和被污染数据的方 法.我推荐一个比较简单的命名约定,因为它可以同时用在面向过程和 ...

  6. HTML标签汇总

    标签 描述 DTD(Document Type Definition) <!-- --> 定义html注释 STF <a> 定义链接或者锚点 STF <abbr> ...

  7. cmd for备忘

    =============参数 /d (参数只能显示当前目录下的目录名字)=================== rem 显示d:\work\目录下与*.txt相匹配的文件(如果报错就%i-> ...

  8. 魔法禁书目录2:回家(codevs 3024)

    题目描述 Description 大妈打完三战回家,我知道他是怎么回来的,欧洲到日本有L个站点他决定乘坐恰好n次飞机(不是学院都市的超音速飞机)和m次火车来从第一个站点到达最后一个站点.但是有一点很重 ...

  9. merge

    当两个DataFrame相加的时候,如果,其中一个不全则会相加产生NA,所以必须一次性将数据的索引索引确定下来,然后对所有数据重建索引然后,填充0,再相加.否则有数据的和没数据的相加结果都变为了NA, ...

  10. Java bean validation 规范与参考实现

    1.Apache Bval 依赖包:validation-api-1.1.0.Final.jar org.apache.bval.bundle-1.1.1.jar bval-core-1.1.1.ja ...