《DSP using MATLAB》Problem 2.5

2、代码:

%% ------------------------------------------------------------------------
%%            Output Info about this m-file
fprintf(‘\n***********************************************************\n‘);
fprintf(‘        <DSP using MATLAB> Problem 2.5.2 \n\n‘);

time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, ‘long‘);
fprintf(‘      Now is %20s, and it is %7s  \n\n‘, time_stamp, wkd2);
%% ------------------------------------------------------------------------

n1 = -100; n2 = 100;
n = [n1:n2];
x = exp(0.1* j * pi* n);
%x = cos(0.1 * n);

set(gcf,‘Color‘,‘white‘);
stem(n,x); title(‘exp(0.1j\pi n) Sequence‘);
xlabel(‘n‘); ylabel(‘x(n)‘); grid on;

figure
set(gcf,‘Color‘,‘white‘);
stem(n,real(x)); title(‘exp(0.1j\pi n) Real Part Sequence‘);
xlabel(‘n‘); ylabel(‘Real[x(n)]‘); grid on;

figure
set(gcf,‘Color‘,‘white‘);
stem(n,imag(x)); title(‘exp(0.1j\pi n) Imaginary Part Sequence‘);
xlabel(‘n‘); ylabel(‘Imag[x(n)]‘); grid on;

figure
set(gcf,‘Color‘,‘white‘);
stem(n,abs(x)); title(‘exp(0.1j\pi n) Magnitude Sequence‘);
xlabel(‘n‘); ylabel(‘|x(n)|‘); grid on;

figure
set(gcf,‘Color‘,‘white‘);
stem(n,(180/pi) * angle(x)); title(‘exp(0.1j\pi n) Phase Sequence‘);
xlabel(‘n‘); ylabel(‘phase[x(n)]‘); grid on;

  运行结果:

3、代码:

%% ------------------------------------------------------------------------
%%            Output Info about this m-file
fprintf(‘\n***********************************************************\n‘);
fprintf(‘        <DSP using MATLAB> Problem 2.5.3 \n\n‘);

time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, ‘long‘);
fprintf(‘      Now is %20s, and it is %7s  \n\n‘, time_stamp, wkd2);
%% ------------------------------------------------------------------------

n1 = -20; n2 = 20;
n = [n1:n2];
%x = exp(0.1* j * pi* n);
x = cos(0.1 * n);

set(gcf,‘Color‘,‘white‘);
stem(n,x); title(‘cos(0.1n) Sequence‘);
xlabel(‘n‘); ylabel(‘x(n)‘); grid on;

  运行结果:

时间: 2024-11-11 21:25:22

《DSP using MATLAB》Problem 2.5的相关文章

《DSP using MATLAB》 Problem 2.3

本题主要是显示周期序列的. 1.代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.3.1 \

《DSP using MATLAB》Problem 2.6

1.代码 %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.6.1 \n\n'); [v, d] =

《DSP using MATLAB》Problem 2.8

1.代码: 从MATLAB官方网上下载的. %*************************************************************************% %A code for the Downsampler% %Author: Yashwant Marathe% %Date:20-12-2010% function [y ny] = dnsample(x,n,M) %x is a sequence over indices specified by v

《DSP using MATLAB》Problem 2.14

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.14 \n\n'); banner();

《DSP using MATLAB》Problem 2.16

先由脉冲响应序列h(n)得到差分方程系数,过程如下: 代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Prob

《DSP using MATLAB》Problem 2.15

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.15 \n\n'); banner();

《DSP using MATLAB》Problem 2.19

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.19 \n\n'); banner();

《DSP using MATLAB》Problem 2.20

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.20 \n\n'); banner();

《DSP using MATLAB》Problem 3.1

先写DTFT子函数: function [X] = dtft(x, n, w) %% ------------------------------------------------------------------------ %% Computes DTFT (Discrete-Time Fourier Transform) %% of Finite-Duration Sequence %% Note: NOT the most elegant way % [X] = dtft(x, n,