上代码:

x1 = rand(1,11); x2 = rand(1,11); n = 0:10;
alpha = 2; beta = 3; k = 0:500;
w = (pi/500)*k; % [0,pi] axis divided into 501 points. X1 = x1 * (exp(-j*pi/500)) .^ (n'*k); % DTFT of x1
X2 = x2 * (exp(-j*pi/500)) .^ (n'*k); % DTFT of x2 x = alpha * x1 + beta * x2; % Linear combination of x1 & x2
X = x * (exp(-j*pi/500)) .^ (n'*k); % DTFT of x magX1 = abs(X1); angX1 = angle(X1); realX1 = real(X1); imagX1 = imag(X1);
magX2 = abs(X2); angX2 = angle(X2); realX2 = real(X2); imagX2 = imag(X2);
magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X); %verification
X_check = alpha*X1 + beta*X2; % Linear combination of X1 & X2
error = max(abs(X-X_check)); % Difference %% --------------------------------------------------------------
%% START X1's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'X1 its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX1); grid on; % axis([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X1|');
subplot(2,2,3); plot(w/pi, angX1/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, realX1); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagX1); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% --------------------------------------------------------------
%% END X1's mag ang real imag
%% -------------------------------------------------------------- %% --------------------------------------------------------------
%% START X2's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'X2 its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX2); grid on; % axis([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X2|');
subplot(2,2,3); plot(w/pi, angX2/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, realX2); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagX2); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% --------------------------------------------------------------
%% END X2's mag ang real imag
%% -------------------------------------------------------------- %% --------------------------------------------------------------
%% 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
%% --------------------------------------------------------------

结果:

  

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

  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.22

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

  7. DSP using MATLAB 示例Example3.17

  8. DSP using MATLAB 示例 Example3.15

    上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figur ...

  9. DSP using MATLAB 示例 Example3.13

    上代码: w = [0:1:500]*pi/500; % freqency between 0 and +pi, [0,pi] axis divided into 501 points. H = ex ...

  10. DSP using MATLAB 示例 Example3.12

    用到的性质 代码: n = -5:10; x = sin(pi*n/2); k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , ...

随机推荐

  1. 绿色通道(codevs 3342)

    题目描述 Description <思远高考绿色通道>(Green Passage, GP)是唐山一中常用的练习册之一,其题量之大深受lsz等许多oiers的痛恨,其中又以数学绿色通道为最 ...

  2. iOS中常见的一些宏

    原文链接 1.处理NSLog事件(开发者模式打印,发布者模式不打印) #ifdef DEBUG #define NSLog(FORMAT, ...) fprintf(stderr,"%s:% ...

  3. web页面记住密码存在安全问题 - 处理方式

    现在一般安全网站都不会做记住密码功能,因为记住密码存在安全缺陷. 不考虑网络拦截问题,如果是登录页面记住密码,第二次登录,直接进入开发者模式修改类型为text即可看到密码. 处理方式: 1.把auto ...

  4. 三、jQuery--jQuery实践--瀑布流布局

    实现方法: 1.JavaScript 2.jQuery 3.CSS多栏布局 法一: window.onload=function(){ waterfall('main','pin'); var dat ...

  5. sshd_conf AllowUsers参数

    AllowUsers root user1 user2 #服务器只允许root user1 user2登录,再的新也用户产生,是不允许豋录服务器 配置文件在/etc/ssh/sshd_confing ...

  6. CLR via C#(11)-无参属性、有参数属性(索引器)

    一. 无参属性 1. 定义属性 无参属性就是我们最常见的属性方式,在赋值时可以加入一定的逻辑判断.属性的定义其实不复杂,先看个直观的例子: 说明: 属性要定义名称和类型,且类型不能是void. 属性是 ...

  7. Tensorflow 的Word2vec demo解析

    简单demo的代码路径在tensorflow\tensorflow\g3doc\tutorials\word2vec\word2vec_basic.py Sikp gram方式的model思路 htt ...

  8. ASP.NET Web API 数据验证

    第一种方式单独为每一个Action做验证 // POST api/values public HttpResponseMessage Post([FromBody]UserInfo userInfo) ...

  9. 【转载】 python修饰符@

    @符号在python语言中具有特殊含义,用来作为修饰符使用, @修饰符有点像函数指针,python解释器发现执行的时候如果碰到@修饰的函数,首先就解析它,找到它对应的函数进行调用,并且会把@修饰下面一 ...

  10. iscroll 4.0 滚动(水平和垂直)

    1.概述 iscroll 专注于页面滚动js.Iscroll滚动做的挺好,特别是针对手机网页(android.iphone)正好弥补手动滑屏的遗缺,而今研究一番,把代码贴出来,供大家参考. 2.isc ...