1. 程式人生 > >【 MATLAB 】畫出一個復指數序列的幅度、相位、實部和虛部的MATLAB指令碼

【 MATLAB 】畫出一個復指數序列的幅度、相位、實部和虛部的MATLAB指令碼

該復指數序列為:

x(n) = e^{(-0.1+j0.3)n},-10 \leq n \leq 10

直接給出MATLAB指令碼:

clc
clear
close all

n = [-10:10];
alpha = -0.1 + 0.3j;
x = exp(alpha*n);

subplot(2,2,1);
stem(n,real(x),'filled');
title('real part');
xlabel('n');
ylim([-3,2]);

subplot(2,2,2);
stem(n,imag(x),'filled');
title('imaginary part');
xlabel('n');

subplot(2,2,3);
stem(n,abs(x),'filled');
title('magnitude part');
xlabel('n');

subplot(2,2,4);
stem(n,(180/pi)*angle(x),'filled');
title('phase part');
xlabel('n');