Sunday 10 February 2013

Matlab functions

subplot(3,3,1);
stem([1;zeros(49,1)]);
title('Dirac pulse')
subplot(3,3,2); stem(ones(50,1));
title('Step function')
subplot(3,3,3);
stem([ones(1,5),zeros(1,3)])
title('Rectangular pulse')
subplot(3,3,4);
stem(sin(2*pi/8*(0:15)))
title('Sinusoidal signal')
subplot(3,3,5); stem(sinc(0:0.25:8));
title('"Sinc" signal')
subplot(3,3,6); stem(exp(-(0:15)));
title('e^-^n signal')
subplot(3,3,7);
stem(pow2(-0.5*(0:15)))
title('2^-^0^.^5^n signal')
subplot(3,3,8); stem(3.^(0:15));
title('3^n signal')
subplot(3,3,9); stem(randn(1,16));
title('Gaussian random signal');

%Generate the following signal:
%x(n) = K exp[c n] ,
%where: K = 2, c = −1/12 + jπ / 6 , n􀁠 and n = 0..40 .
c = -(1/12)+(pi/6)*i;
K = 2; n = 0:40;
x = K*exp(c*n);
subplot(2,1,1); stem(n,real(x));
xlabel('Time index n');
ylabel('Amplitude');
title('Real part');
subplot(2,1,2); stem(n,imag(x));
xlabel('Time index n');
ylabel('Amplitude');
title('Imaginary part');

0 comments:

Post a Comment