Vous êtes sur la page 1sur 30

ÑALES14 ÑALESÑALES26 ÑALESÑALES38 ÑALESÑALES410 ÑALESÑALES512

ÑALESÑALES614

1
ESCUELA POLITECNICA NACIONAL

Análisis de Señales y Procesos Estocásticos


Luis Eduardo Oña Navarrete Morales

Facultad de Ingenierı́a Eléctrica y Eléctronica


Carrera de Ingenieria en Tecnologias de la Informacion
10 de diciembre de 2018

1. DEBER 1
1.1. Realizar la implementacion directa del archivo.m
Instrucciones
Para las siguientes seniales, graficar
a) Senial en tiempo x[n]
b) Espectro de magnitud bilateral
c) Espectro de fase bilateral
b) Espectro de magnitud unilateral
c) Espectro de fase unilateral
c) Parte real bilateral
c) Parte imaginaria bilateral
c) Senial en tiempo calculada con ifft

Observaciones:
1. Use fft e ifft
2. Use fftshift para obtener las graficas bilaterales

2
1. x[n] = δ[n] para N = 64

1.1. CODIGO FUENTE

1 % % x[n] =\delta[n] para N = 64


2 clear all
3 close all
4 clc
5 N = 64; % numero de muestras
6 n =0:N-1; % espacio muestral n
7 k=n; %el espacio muestral en k es el mismo que en n
8 Fs=1; %frecuencia de muestreo
9 t=n*Fs; %vector de tiempo para la ifft
10 x =dirac(n) ;
11 idx=x==Inf;
12 x(idx)=1; % implementacion de la delta de dirac
13 X = fft(x)/N; % s e al X[k] normalizada
14 X_unilateral=X(1:floor(N/2)+1); % parte unilateral
15
16 subplot(4,2,1) % s e al x[n]
17 stem(n, x)
18 title (' S e al en tiempo x[n]')
19 xlabel('n')
20 axis([-3 68 0 1.2])
21
22 subplot(4,2,2) % magnitud
23 stem(linspace(-N/2,N/2-1,N), abs(fftshift(X))) % aplicacion de
fftshift para la obtencion del espectro bilateral
24 title ('Espectro de magnitud Bilateral')
25 xlabel('k')
26 ylabel('mod[X[k]]')
27 subplot(4,2,3) %fase
28 stem(linspace(-N/2,N/2-1,N), angle(fftshift(X)))
29 title ('Espectro de fase bilateral')
30 xlabel('k')
31 ylabel('Arg[X[k]]')
32 subplot(4,2,4)
33 stem(linspace(0, Fs/2, floor(N/2)+1), 2*abs(X_unilateral)) %
grafica unilateral
34 title ('Espectro de magnitud unilateral')
35 xlabel('k')
36 ylabel('Mod[X[k]]')
37 subplot(4,2,5)
38 stem(linspace(0, Fs/2, floor(N/2)+1), 2*angle(X_unilateral))
39 title ('Espectro de fase unilateral')
40 xlabel('k')
41 ylabel('Arg[X[k]]')
42 subplot(4,2,6)
43 stem(linspace(-N/2,N/2-1,N), real(fftshift(X))) %N par
44 title ('Parte real bilateral')
45 xlabel('k')
46 ylabel('Re[X[k]]')
47 subplot(4,2,7)
48 stem(linspace(-N/2,N/2-1,N), imag(fftshift(X))) %N par

3
49 title ('Parte imaginaria bilateral')
50 xlabel('k')
51 ylabel('Imag[X[k]]')
52 x_ifft=ifft(X)*N
53 subplot(4,2,8)
54 stem(t(1:64), x_ifft(1:64))
55 title (' S e al en tiempo calculada con ifft')
56 xlabel('t')
57 axis([-3 68 0 1.2])

1.2. GRAFICA

Señal en tiempo x[n] Espectro de magnitud Bilateral

mod[X[k]]
1
0.01
0.5
0 0
0 20 40 60 -40 -20 0 20 40
n k
Espectro de fase bilateral Espectro de magnitud unilateral
1

Mod[X[k]]
Arg[X[k]]

0.02
0

-1 0
-40 -20 0 20 40 0 0.1 0.2 0.3 0.4 0.5
k k
Espectro de fase unilateral Parte real bilateral
1
Arg[X[k]]

Re[X[k]]

0.01
0

-1 0
0 0.1 0.2 0.3 0.4 0.5 -40 -20 0 20 40
k k
Parte imaginaria bilateral Señal en tiempo calculada con ifft
Imag[X[k]]

1
1
0 0.5
-1 0
-40 -20 0 20 40 0 20 40 60
k t

Figura 1: GRAFICA DE LA SEÑAL X[n] ESPECTROS BILATERALES Y UNILATERALES CON


SUS RESPECTIVAS PARTES REALES E IMAGINARIAS

4
2. x[n] = 1 para N = 64

2.1. CODIGO FUENTE

1 % % x[n] = 1 para N = 64
2 clear all
3 close all
4 clc
5 N = 64;
6 n = 0:N-1;
7 k=n;
8 Fs=1;
9 t=n*Fs;
10 x = ones(1,N);
11 X = fft(x)/N;
12 X_unilateral=X(1:floor(N/2)+1);
13 subplot(4,2,1)
14 stem(n, x)
15 title (' S e al en tiempo x[n]')
16 xlabel('n')
17 subplot(4,2,2)
18 stem(linspace(-N/2,N/2-1,N), abs(fftshift(X)))
19 title ('Espectro de magnitud Bilateral')
20 xlabel('k')
21 ylabel('mod[X[k]]')
22 subplot(4,2,3)
23 stem(linspace(-N/2,N/2-1,N), angle(fftshift(X)))
24 title ('Espectro de fase bilateral')
25 xlabel('k')
26 ylabel('Arg[X[k]]')
27 subplot(4,2,4)
28 stem(linspace(0, Fs/2, floor(N/2)+1), abs(X_unilateral))
29 title ('Espectro de magnitud unilateral')
30 xlabel('k')
31 ylabel('Mod[X[k]]')
32 axis([-1 0.7 0 1.2])
33 subplot(4,2,5)
34 stem(linspace(0, Fs/2, floor(N/2)+1), angle(X_unilateral))
35 title ('Espectro de fase unilateral')
36 xlabel('k')
37 ylabel('Arg[X[k]]')
38
39 subplot(4,2,6)
40 stem(linspace(-N/2,N/2-1,N), real(fftshift(X))) %N par
41 title ('Parte real bilateral')
42 xlabel('k')
43 ylabel('Re[X[k]]')
44 subplot(4,2,7)
45 stem(linspace(-N/2,N/2-1,N), imag(fftshift(X))) %N par
46 title ('Parte imaginaria bilateral')
47 xlabel('k')
48 ylabel('Imag[X[k]]')
49 x_ifft=ifft(X)*N
50 subplot(4,2,8)

5
51 stem(t(1:64), x_ifft(1:64))
52 title (' S e al en tiempo calculada con ifft')
53 xlabel('t')

2.2. GRAFICA

Señal en tiempo x[n] Espectro de magnitud Bilateral


1 1

mod[X[k]]
0.5 0.5

0 0
0 20 40 60 -40 -20 0 20 40
n k
Espectro de fase bilateral Espectro de magnitud unilateral
1

Mod[X[k]]
Arg[X[k]]

1
0 0.5
-1 0
-40 -20 0 20 40 -1 -0.5 0 0.5
k k
Espectro de fase unilateral Parte real bilateral
1 1
Arg[X[k]]

Re[X[k]]
0 0.5

-1 0
0 0.1 0.2 0.3 0.4 0.5 -40 -20 0 20 40
k k
Parte imaginaria bilateral Señal en tiempo calculada con ifft
Imag[X[k]]

1 1

0 0.5

-1 0
-40 -20 0 20 40 0 20 40 60
k t

Figura 2: GRAFICA DE LA SEÑAL X[n] ESPECTROS BILATERALES Y UNILATERALES CON


SUS RESPECTIVAS PARTES REALES E IMAGINARIAS

6
3. x[n] = 3cos(2πn/16) para N = 64

3.1. CODIGO FUENTE

1 % % x[n] = 3cos(2\pi n/16) para N=64


2 clear all
3 close all
4 clc
5 N = 64;
6 n = 0:N-1;
7 k=n;
8 Fs=1;
9 t=n*Fs;
10 x = 3*cos(2*pi*n/16);
11 X = fft(x)/N;
12 X_unilateral=X(1:floor(N/2)+1);
13 subplot(4,2,1)
14 stem(n, x)
15 title (' S e al en tiempo x[n]')
16 xlabel('n')
17 subplot(4,2,2)
18 stem(linspace(-N/2,N/2-1,N), abs(fftshift(X))) %N par
19 title ('Espectro de magnitud Bilateral')
20 xlabel('k')
21 ylabel('mod[X[k]]')
22 subplot(4,2,3)
23 stem(linspace(-N/2,N/2-1,N), angle(fftshift(X))) %N par
24 title ('Espectro de fase bilateral')
25 xlabel('k')
26 ylabel('Arg[X[k]]')
27
28 subplot(4,2,4)
29 stem(linspace(0, Fs/2, floor(N/2)+1), 2*abs(X_unilateral))
30 title ('Espectro de magnitud unilateral')
31 xlabel('k')
32 ylabel('Mod[X[k]]')
33
34 subplot(4,2,5)
35 stem(linspace(0, Fs/2, floor(N/2)+1), 2*angle(X_unilateral))
36 title ('Espectro de fase unilateral')
37 xlabel('k')
38 ylabel('Arg[X[k]]')
39 subplot(4,2,6)
40 stem(linspace(-N/2,N/2-1,N), real(fftshift(X))) %N par
41 title ('Parte real bilateral')
42 xlabel('k')
43 ylabel('Re[X[k]]')
44 subplot(4,2,7)
45 stem(linspace(-N/2,N/2-1,N), imag(fftshift(X))) %N par
46 title ('Parte imaginaria bilateral')
47 xlabel('k')
48 ylabel('Imag[X[k]]')
49 x_ifft=ifft(X)*N
50 subplot(4,2,8)

7
51 stem(t(1:64), x_ifft(1:64))
52 title (' S e al en tiempo calculada con ifft')
53 xlabel('t')

3.2. GRAFICA

Señal en tiempo x[n] Espectro de magnitud Bilateral


1.5

mod[X[k]]
2
1
0
0.5
-2
0
0 20 40 60 -40 -20 0 20 40
n k
Espectro de fase bilateral Espectro de magnitud unilateral
3

Mod[X[k]]
Arg[X[k]]

2
2
0
1
-2
0
-40 -20 0 20 40 0 0.1 0.2 0.3 0.4 0.5
k k
Espectro de fase unilateral Parte real bilateral
1.5
Arg[X[k]]

Re[X[k]]
5
1
0
0.5
-5 0
0 0.1 0.2 0.3 0.4 0.5 -40 -20 0 20 40
k k
10-15
Parte imaginaria bilateral Señal en tiempo calculada con ifft
Imag[X[k]]

1
2
0 0
-2
-1
-40 -20 0 20 40 0 20 40 60
k t

Figura 3: GRAFICA DE LA SEÑAL X[n] ESPECTROS BILATERALES Y UNILATERALES CON


SUS RESPECTIVAS PARTES REALES E IMAGINARIAS

8
4. x[n] = 3cos(2πn/16 + 3π) para N = 64

4.1. CODIGO FUENTE

1 % % x[n] = 3cos(2\pi n/16 + \pi 3) para N=64


2 clear all
3 close all
4 clc
5 N = 64;
6 n = 0:N-1;
7 k=n;
8 Fs=1;
9 t=n*Fs;
10 x = 3*cos(2*pi*n/16 + 3*pi);
11 X = fft(x)/N;
12 X_unilateral=X(1:floor(N/2)+1);
13 subplot(4,2,1)
14 stem(n, x)
15 title (' S e al en tiempo x[n]')
16 xlabel('n')
17
18 subplot(4,2,2)
19 stem(linspace(-N/2,N/2-1,N), abs(fftshift(X))) %N par
20 title ('Espectro de magnitud Bilateral')
21 xlabel('k')
22 ylabel('mod[X[k]]')
23
24 subplot(4,2,3)
25 stem(linspace(-N/2,N/2-1,N), angle(fftshift(X))) %N par
26 title ('Espectro de fase bilateral')
27 xlabel('k')
28 ylabel('Arg[X[k]]')
29
30 subplot(4,2,4)
31 stem(linspace(0, Fs/2, floor(N/2)+1), 2*abs(X_unilateral))
32 title ('Espectro de magnitud unilateral')
33 xlabel('k')
34 ylabel('Mod[X[k]]')
35
36 subplot(4,2,5)
37 stem(linspace(0, Fs/2, floor(N/2)+1), 2*angle(X_unilateral))
38 title ('Espectro de fase unilateral')
39 xlabel('k')
40 ylabel('Arg[X[k]]')
41
42 subplot(4,2,6)
43 stem(linspace(-N/2,N/2-1,N), real(fftshift(X))) %N par
44 title ('Parte real bilateral')
45 xlabel('k')
46 ylabel('Re[X[k]]')
47
48 subplot(4,2,7)
49 stem(linspace(-N/2,N/2-1,N), imag(fftshift(X))) %N par
50 title ('Parte imaginaria bilateral')

9
51 xlabel('k')
52 ylabel('Imag[X[k]]')
53
54 x_ifft=ifft(X)*N
55
56 subplot(4,2,8)
57 stem(t(1:64), x_ifft(1:64))
58 title (' S e al en tiempo calculada con ifft')
59 xlabel('t')

4.2. GRAFICA

Señal en tiempo x[n] Espectro de magnitud Bilateral

mod[X[k]]
2
1
0
0.5
-2
0
0 20 40 60 -40 -20 0 20 40
n k
Espectro de fase bilateral Espectro de magnitud unilateral

Mod[X[k]]
Arg[X[k]]

2
2
0
1
-2
0
-40 -20 0 20 40 0 0.1 0.2 0.3 0.4 0.5
k k
Espectro de fase unilateral Parte real bilateral
0
Arg[X[k]]

Re[X[k]]

5
-0.5
0
-1
-5
0 0.1 0.2 0.3 0.4 0.5 -40 -20 0 20 40
k k
10-15
Parte imaginaria bilateral Señal en tiempo calculada con ifft
Imag[X[k]]

1 2
0 0
-1 -2
-40 -20 0 20 40 0 20 40 60
k t

Figura 4: GRAFICA DE LA SEÑAL X[n] ESPECTROS BILATERALES Y UNILATERALES CON


SUS RESPECTIVAS PARTES REALES E IMAGINARIAS

10
5. x[n] = 3cos(2πn/10) para N = 65 (ojo N es impar)

5.1. CODIGO FUENTE

1 % % x[n] = 3cos(2\pi n/10) para N = 65 (ojo N es impar)


2 clear all
3 close all
4 clc
5 N = 65;
6 n = 0:N-1;
7 k=n;
8 Fs=1;
9 t=n*Fs; %vector de tiempo para la ifft
10 x = 3*cos(2*pi*n/10);
11 X = fft(x)/N;
12 X_unilateral=X(1:floor(N/2)+1); %formula general sea N par o impar
13 X_unilateral(2:end) = 2*X_unilateral(2:end); % al ser N impar no
se resta uno
14 subplot(4,2,1)
15 stem(n, x)
16 title (' S e al en tiempo x[n]')
17 xlabel('n')
18 subplot(4,2,2)
19 stem(k, abs(fftshift(X)))
20 title ('Espectro de magnitud Bilateral')
21 xlabel('k')
22 ylabel('mod[X[k]]')
23 subplot(4,2,3)
24 stem(k, angle(fftshift(X)))
25 title ('Espectro de fase bilateral')
26 xlabel('k')
27 ylabel('Arg[X[k]]')
28
29 subplot(4,2,4)
30 stem(linspace(0, Fs/2, floor(N/2)+1), abs(X_unilateral))
31 title ('Espectro de magnitud unilateral')
32 xlabel('k')
33 ylabel('Mod[X[k]]')
34
35 subplot(4,2,5)
36 stem(linspace(0, Fs/2, floor(N/2)+1), angle(X_unilateral))
37 title ('Espectro de fase unilateral')
38 xlabel('k')
39 ylabel('Arg[X[k]]')
40
41 subplot(4,2,6)
42 stem(k, real(fftshift(X)))
43 title ('Parte real bilateral')
44 xlabel('k')
45 ylabel('Re[X[k]]')
46 subplot(4,2,7)
47 stem(k, imag(fftshift(X)))
48 title ('Parte imaginaria bilateral')
49 xlabel('k')

11
50 ylabel('Imag[X[k]]')
51 x_ifft=ifft(X)*N
52 subplot(4,2,8)
53 stem(t(1:65), x_ifft(1:65))
54 title (' S e al en tiempo calculada con ifft')
55 xlabel('t')

5.2. GRAFICA

Señal en tiempo x[n] Espectro de magnitud Bilateral


1

mod[X[k]]
2
0 0.5
-2
0
0 20 40 60 80 0 20 40 60 80
n k
Espectro de fase bilateral Espectro de magnitud unilateral
2 2

Mod[X[k]]
Arg[X[k]]

0 1

-2 0
0 20 40 60 80 0 0.1 0.2 0.3 0.4 0.5
k k
Espectro de fase unilateral Parte real bilateral
2 0.05
Arg[X[k]]

Re[X[k]]

-2 0
0 0.1 0.2 0.3 0.4 0.5 0 20 40 60 80
k k
Parte imaginaria bilateral Señal en tiempo calculada con ifft
Imag[X[k]]

1
2
0 0
-2
-1
0 20 40 60 80 0 20 40 60 80
k t

Figura 5: GRAFICA DE LA SEÑAL X[n] ESPECTROS BILATERALES Y UNILATERALES CON


SUS RESPECTIVAS PARTES REALES E IMAGINARIAS

12
6. x[n] = 1 para 0 <= n <= 3,N = 65 (ojo N es impar)

6.1. CODIGO FUENTE

1 % % x[n] = 1 para 0 <= n <= 3. N = 65 (ojo N es impar)


2 clear all
3 close all
4 clc
5 N = 65;
6 n = linspace(0,3,65);
7 k=n;
8 Fs=1;
9 t=n*Fs;
10 x = ones(1,N);
11 X = fft(x)/N;
12 X_unilateral=X(1:floor(N/2)+1);
13 X_unilateral(2:end)=2*X_unilateral(2:end);
14 subplot(4,2,1)
15 stem(n, x)
16 title (' S e al en tiempo x[n]')
17 xlabel('n')
18 subplot(4,2,2)
19 stem(k, abs(fftshift(X)))
20 title ('Espectro de magnitud Bilateral')
21 xlabel('k')
22 ylabel('mod[X[k]]')
23 subplot(4,2,3)
24 stem(k, angle(fftshift(X)))
25 title ('Espectro de fase bilateral')
26 xlabel('k')
27 ylabel('Arg[X[k]]')
28 subplot(4,2,4)
29 stem(linspace(0, Fs/2, floor(N/2)+1), abs(X_unilateral))
30 title ('Espectro de magnitud unilateral')
31 xlabel('k')
32 ylabel('Mod[X[k]]')
33 axis([-1 0.7 0 1.2])
34 subplot(4,2,5)
35 stem(linspace(0, Fs/2, floor(N/2)+1), angle(X_unilateral))
36 title ('Espectro de fase unilateral')
37 xlabel('k')
38 ylabel('Arg[X[k]]')
39
40 subplot(4,2,6)
41 stem(k, real(fftshift(X)))
42 title ('Parte real bilateral')
43 xlabel('k')
44 ylabel('Re[X[k]]')
45 subplot(4,2,7)
46 stem(k, imag(fftshift(X)))
47 title ('Parte imaginaria bilateral')
48 xlabel('k')
49 ylabel('Imag[X[k]]')
50 x_ifft=ifft(X)*N

13
51 subplot(4,2,8)
52 stem(t(1:65), x_ifft(1:65))
53 title (' S e al en tiempo calculada con ifft')
54 xlabel('t')

6.2. GRAFICA

Señal en tiempo x[n] Espectro de magnitud Bilateral


1 1

mod[X[k]]
0.5 0.5

0 0
0 1 2 3 0 1 2 3
n k
Espectro de fase bilateral Espectro de magnitud unilateral
1

Mod[X[k]]
Arg[X[k]]

1
0 0.5
-1 0
0 1 2 3 -1 -0.5 0 0.5
k k
Espectro de fase unilateral Parte real bilateral
1 1
Arg[X[k]]

0 Re[X[k]] 0.5

-1 0
0 0.1 0.2 0.3 0.4 0.5 0 1 2 3
k k
Parte imaginaria bilateral Señal en tiempo calculada con ifft
Imag[X[k]]

1 1

0 0.5

-1 0
0 1 2 3 0 1 2 3
k t

Figura 6: GRAFICA DE LA SEÑAL X[n] ESPECTROS BILATERALES Y UNILATERALES CON


SUS RESPECTIVAS PARTES REALES E IMAGINARIAS

14
2. DEBER 2
2.1. Consultar sobre el zero padding
Zero Padding o El relleno cero es un concepto simple; simplemente se refiere a agregar ceros al
final de una señal de dominio de tiempo para aumentar su longitud.Las formas de onda sinusoidales
que se utilizan como ejemplo son de 1 MHz y 1,05 MHz respectivamente a continuacion se muestra
la grafica:

La longitud del dominio del tiempo de esta forma de onda es de 1000 muestras. A la frecuencia de
muestreo de 100 MHz, es una duración de 10 us. Si ajustamos a cero la forma de onda con 1000
muestras adicionales (o 10 datos de datos), se produce la forma de onda resultante:

Hay algunas razones por las que puede querer rellenar los datos del dominio del tiempo. La razón
más común es hacer que una forma de onda tenga una potencia de dos muestras.

15
3. DEBER 3
3.1. Consultar como estimar directamente la amplitud
El relleno cero le permite obtener estimaciones de amplitud más precisas de los componentes
de señal que se pueden resolver. Por otro lado, el relleno cero no mejora la resolución espectral
(frecuencia) de la DFT. La resolución está determinada por el número de muestras y la frecuencia de
muestreo.

16
4. ANEXOS

17
Table of Contents
INSTRUCCIONES .............................................................................................................. 1
x[n] =\delta[n] para N = 64 .................................................................................................. 1
x[n] = 1 para N = 64 ........................................................................................................... 3
x[n] = 3cos(2\pi n/16) para N=64 .......................................................................................... 5
x[n] = 3cos(2\pi n/16 + \pi 3) para N=64 ................................................................................ 7
x[n] = 3cos(2\pi n/10) para N = 65 (ojo N es impar) ................................................................. 9
x[n] = 1 para 0 <= n <= 3. N = 65 (ojo N es impar) ................................................................ 11

INSTRUCCIONES
%Para las siguientes seniales, graficar
% a) Senial en tiempo x[n]
% b) Espectro de magnitud bilateral
% c) Espectro de fase bilateral
% b) Espectro de magnitud unilateral
% c) Espectro de fase unilateral
% c) Parte real bilateral
% c) Parte imaginaria bilateral
% c) Senial en tiempo calculada con ifft
%
% OBservaciones:
% 1. Use fft e ifft
% 2. Use fftshift para obtener las graficas bilaterales

x[n] =\delta[n] para N = 64


clear all
close all
clc
N = 64; % numero de muestras
n =0:N-1; % espacio muestral n
k=n; %el espacio muestral en k es el mismo que en n
Fs=1; %frecuencia de muestreo
t=n*Fs; %vector de tiempo para la ifft
x =dirac(n) ;
idx=x==Inf;
x(idx)=1; % implementacion de la delta de dirac
X = fft(x)/N; % señal X[k] normalizada
X_unilateral=X(1:floor(N/2)+1); % parte unilateral

subplot(4,2,1) % señal x[n]


stem(n, x)
title ('Señal en tiempo x[n]')
xlabel('n')
axis([-3 68 0 1.2])

subplot(4,2,2) % magnitud
stem(linspace(-N/2,N/2-1,N), abs(fftshift(X))) % aplicacion de
fftshift para la obtencion del espectro bilateral

1
title ('Espectro de magnitud Bilateral')
xlabel('k')
ylabel('mod[X[k]]')
subplot(4,2,3) %fase
stem(linspace(-N/2,N/2-1,N), angle(fftshift(X)))
title ('Espectro de fase bilateral')
xlabel('k')
ylabel('Arg[X[k]]')
subplot(4,2,4)
stem(linspace(0, Fs/2, floor(N/2)+1), 2*abs(X_unilateral)) % grafica
unilateral
title ('Espectro de magnitud unilateral')
xlabel('k')
ylabel('Mod[X[k]]')
subplot(4,2,5)
stem(linspace(0, Fs/2, floor(N/2)+1), 2*angle(X_unilateral))
title ('Espectro de fase unilateral')
xlabel('k')
ylabel('Arg[X[k]]')
subplot(4,2,6)
stem(linspace(-N/2,N/2-1,N), real(fftshift(X))) %N par
title ('Parte real bilateral')
xlabel('k')
ylabel('Re[X[k]]')
subplot(4,2,7)
stem(linspace(-N/2,N/2-1,N), imag(fftshift(X))) %N par
title ('Parte imaginaria bilateral')
xlabel('k')
ylabel('Imag[X[k]]')
x_ifft=ifft(X)*N;
subplot(4,2,8)
stem(t(1:64), x_ifft(1:64))
title ('Señal en tiempo calculada con ifft')
xlabel('t')
axis([-3 68 0 1.2])

2
x[n] = 1 para N = 64
clear all
close all
clc
N = 64;
n = 0:N-1;
k=n;
Fs=1;
t=n*Fs;
x = ones(1,N);
X = fft(x)/N;
X_unilateral=X(1:floor(N/2)+1);
subplot(4,2,1)
stem(n, x)
title ('Señal en tiempo x[n]')
xlabel('n')
subplot(4,2,2)
stem(linspace(-N/2,N/2-1,N), abs(fftshift(X)))
title ('Espectro de magnitud Bilateral')
xlabel('k')
ylabel('mod[X[k]]')
subplot(4,2,3)
stem(linspace(-N/2,N/2-1,N), angle(fftshift(X)))
title ('Espectro de fase bilateral')

3
xlabel('k')
ylabel('Arg[X[k]]')
subplot(4,2,4)
stem(linspace(0, Fs/2, floor(N/2)+1), abs(X_unilateral))
title ('Espectro de magnitud unilateral')
xlabel('k')
ylabel('Mod[X[k]]')
axis([-1 0.7 0 1.2])
subplot(4,2,5)
stem(linspace(0, Fs/2, floor(N/2)+1), angle(X_unilateral))
title ('Espectro de fase unilateral')
xlabel('k')
ylabel('Arg[X[k]]')

subplot(4,2,6)
stem(linspace(-N/2,N/2-1,N), real(fftshift(X))) %N par
title ('Parte real bilateral')
xlabel('k')
ylabel('Re[X[k]]')
subplot(4,2,7)
stem(linspace(-N/2,N/2-1,N), imag(fftshift(X))) %N par
title ('Parte imaginaria bilateral')
xlabel('k')
ylabel('Imag[X[k]]')
x_ifft=ifft(X)*N;
subplot(4,2,8)
stem(t(1:64), x_ifft(1:64))
title ('Señal en tiempo calculada con ifft')
xlabel('t')

4
x[n] = 3cos(2\pi n/16) para N=64
clear all
close all
clc
N = 64;
n = 0:N-1;
k=n;
Fs=1;
t=n*Fs;
x = 3*cos(2*pi*n/16);
X = fft(x)/N;
X_unilateral=X(1:floor(N/2)+1);
subplot(4,2,1)
stem(n, x)
title ('Señal en tiempo x[n]')
xlabel('n')
subplot(4,2,2)
stem(linspace(-N/2,N/2-1,N), abs(fftshift(X))) %N par
title ('Espectro de magnitud Bilateral')
xlabel('k')
ylabel('mod[X[k]]')
subplot(4,2,3)
stem(linspace(-N/2,N/2-1,N), angle(fftshift(X))) %N par
title ('Espectro de fase bilateral')

5
xlabel('k')
ylabel('Arg[X[k]]')

subplot(4,2,4)
stem(linspace(0, Fs/2, floor(N/2)+1), 2*abs(X_unilateral))
title ('Espectro de magnitud unilateral')
xlabel('k')
ylabel('Mod[X[k]]')

subplot(4,2,5)
stem(linspace(0, Fs/2, floor(N/2)+1), 2*angle(X_unilateral))
title ('Espectro de fase unilateral')
xlabel('k')
ylabel('Arg[X[k]]')
subplot(4,2,6)
stem(linspace(-N/2,N/2-1,N), real(fftshift(X))) %N par
title ('Parte real bilateral')
xlabel('k')
ylabel('Re[X[k]]')
subplot(4,2,7)
stem(linspace(-N/2,N/2-1,N), imag(fftshift(X))) %N par
title ('Parte imaginaria bilateral')
xlabel('k')
ylabel('Imag[X[k]]')
x_ifft=ifft(X)*N;
subplot(4,2,8)
stem(t(1:64), x_ifft(1:64))
title ('Señal en tiempo calculada con ifft')
xlabel('t')

6
x[n] = 3cos(2\pi n/16 + \pi 3) para N=64
clear all
close all
clc
N = 64;
n = 0:N-1;
k=n;
Fs=1;
t=n*Fs;
x = 3*cos(2*pi*n/16 + 3*pi);
X = fft(x)/N;
X_unilateral=X(1:floor(N/2)+1);
subplot(4,2,1)
stem(n, x)
title ('Señal en tiempo x[n]')
xlabel('n')

subplot(4,2,2)
stem(linspace(-N/2,N/2-1,N), abs(fftshift(X))) %N par
title ('Espectro de magnitud Bilateral')
xlabel('k')
ylabel('mod[X[k]]')

subplot(4,2,3)

7
stem(linspace(-N/2,N/2-1,N), angle(fftshift(X))) %N par
title ('Espectro de fase bilateral')
xlabel('k')
ylabel('Arg[X[k]]')

subplot(4,2,4)
stem(linspace(0, Fs/2, floor(N/2)+1), 2*abs(X_unilateral))
title ('Espectro de magnitud unilateral')
xlabel('k')
ylabel('Mod[X[k]]')

subplot(4,2,5)
stem(linspace(0, Fs/2, floor(N/2)+1), 2*angle(X_unilateral))
title ('Espectro de fase unilateral')
xlabel('k')
ylabel('Arg[X[k]]')

subplot(4,2,6)
stem(linspace(-N/2,N/2-1,N), real(fftshift(X))) %N par
title ('Parte real bilateral')
xlabel('k')
ylabel('Re[X[k]]')

subplot(4,2,7)
stem(linspace(-N/2,N/2-1,N), imag(fftshift(X))) %N par
title ('Parte imaginaria bilateral')
xlabel('k')
ylabel('Imag[X[k]]')

x_ifft=ifft(X)*N;

subplot(4,2,8)
stem(t(1:64), x_ifft(1:64))
title ('Señal en tiempo calculada con ifft')
xlabel('t')

8
x[n] = 3cos(2\pi n/10) para N = 65 (ojo N es im-
par)
clear all
close all
clc
N = 65;
n = 0:N-1;
k=n;
Fs=1;
t=n*Fs; %vector de tiempo para la ifft
x = 3*cos(2*pi*n/10);
X = fft(x)/N;
X_unilateral=X(1:floor(N/2)+1); %formula general sea N par o impar
X_unilateral(2:end) = 2*X_unilateral(2:end); % al ser N impar no se
resta uno
subplot(4,2,1)
stem(n, x)
title ('Señal en tiempo x[n]')
xlabel('n')
subplot(4,2,2)
stem(k, abs(fftshift(X)))
title ('Espectro de magnitud Bilateral')
xlabel('k')

9
ylabel('mod[X[k]]')
subplot(4,2,3)
stem(k, angle(fftshift(X)))
title ('Espectro de fase bilateral')
xlabel('k')
ylabel('Arg[X[k]]')

subplot(4,2,4)
stem(linspace(0, Fs/2, floor(N/2)+1), abs(X_unilateral))
title ('Espectro de magnitud unilateral')
xlabel('k')
ylabel('Mod[X[k]]')

subplot(4,2,5)
stem(linspace(0, Fs/2, floor(N/2)+1), angle(X_unilateral))
title ('Espectro de fase unilateral')
xlabel('k')
ylabel('Arg[X[k]]')

subplot(4,2,6)
stem(k, real(fftshift(X)))
title ('Parte real bilateral')
xlabel('k')
ylabel('Re[X[k]]')
subplot(4,2,7)
stem(k, imag(fftshift(X)))
title ('Parte imaginaria bilateral')
xlabel('k')
ylabel('Imag[X[k]]')
x_ifft=ifft(X)*N;
subplot(4,2,8)
stem(t(1:65), x_ifft(1:65))
title ('Señal en tiempo calculada con ifft')
xlabel('t')

10
x[n] = 1 para 0 <= n <= 3. N = 65 (ojo N es im-
par)
clear all
close all
clc
N = 65;
n = linspace(0,3,65);
k=n;
Fs=1;
t=n*Fs;
x = ones(1,N);
X = fft(x)/N;
X_unilateral=X(1:floor(N/2)+1);
X_unilateral(2:end)=2*X_unilateral(2:end);
subplot(4,2,1)
stem(n, x)
title ('Señal en tiempo x[n]')
xlabel('n')
subplot(4,2,2)
stem(k, abs(fftshift(X)))
title ('Espectro de magnitud Bilateral')
xlabel('k')
ylabel('mod[X[k]]')

11
subplot(4,2,3)
stem(k, angle(fftshift(X)))
title ('Espectro de fase bilateral')
xlabel('k')
ylabel('Arg[X[k]]')
subplot(4,2,4)
stem(linspace(0, Fs/2, floor(N/2)+1), abs(X_unilateral))
title ('Espectro de magnitud unilateral')
xlabel('k')
ylabel('Mod[X[k]]')
axis([-1 0.7 0 1.2])
subplot(4,2,5)
stem(linspace(0, Fs/2, floor(N/2)+1), angle(X_unilateral))
title ('Espectro de fase unilateral')
xlabel('k')
ylabel('Arg[X[k]]')

subplot(4,2,6)
stem(k, real(fftshift(X)))
title ('Parte real bilateral')
xlabel('k')
ylabel('Re[X[k]]')
subplot(4,2,7)
stem(k, imag(fftshift(X)))
title ('Parte imaginaria bilateral')
xlabel('k')
ylabel('Imag[X[k]]')
x_ifft=ifft(X)*N;
subplot(4,2,8)
stem(t(1:65), x_ifft(1:65))
title ('Señal en tiempo calculada con ifft')
xlabel('t')

12
Published with MATLAB® R2018b

13

Vous aimerez peut-être aussi