Anda di halaman 1dari 7

GENERACION DE PULSOS Y TREN DE PULSOS

%% 1) Funcion pulso rectangular (rectpuls)


% Centrada en 5, de amplitud 2, y duracin 10
clc
clear
close all
D = 6; % cambiar luego a 10
C = 5;
x = linspace(-20, 20, 13000);
y = 2*rectpuls(x, D); % cambiar x --> x-C, despues de cambiar D
plot(x, y, 'Linewidth', 2);
ylim([-2 3])
grid on
%% 2) Funcion Pulso Rectangular (dos escalones)
% Centrada en 5, de amplitud 2, y duracion 10
clc
clear
close all
x = linspace(-20, 20, 13000);
y = 2*(heaviside(x) heaviside(x-10));
plot(x, y, 'r', 'Linewidth', 2);
ylim([-2 3])
grid on

%% 3) Funcion Pulso triangular (tripuls)


% Centrada en 5, duracion 10;
clc
clear
close all
D = 10;
C = 5;
x = linspace(-20, 20, 10000);
y = 2*tripuls(x-C,D,0); % el tercer parmetro varia entre -1 y 1
plot(x, y, 'Linewidth', 2);
ylim([-2 3])
grid on
%% 4) Tren de pulsos (pulstran)
% Periodo: 10, Duracion: 8, Numero de pulsos: 10;
clc
clear
close all
T = 10;
D = 5;
N = 10;
x = linspace(0, T*N, 10000);
d = [0:T:T*N];
y = pulstran(x, d,'rectpuls', D); % cambiar x x-D/2
plot(x, y, 'Linewidth', 2);
ylim([-1 2])
grid on
%% 5) Tren de pulsos (square)
% Periodo: 10, Duracion: 8, Numero de pulsos: 10;
clc
clear
close all
T = 10;
N = 10;
D = 8;
f = 1/T;
x = linspace(0, N*D, 10000);
d = [0:T:T*N];
y = square(2*pi*f*x, 50);
plot(x, y, 'LineWidth', 2);
ylim([-2 2])
grid on
%% 6) Funciones triangulares. Diente de sierra (sawtooth)
% Periodo: 10, Numero de pulsos: 10;
clc
clear
close all

T = 20;
N = 10;
f = 1/T;
x = linspace(0, T*N, 10000);
y = sawtooth(2*pi*f*x, 0); & el tercer parametro varia entre 0 y 1
plot(x, y, 'LineWidth', 2);
ylim([-2 2])
grid on
%% 7) Tren de Pulsos Triangulares (pulstran)
% Periodo: 10, Duracion: 5, Numero de pulsos: 10;
clc
clear
close all

T = 10;
D = 5;
N = 10;
x = linspace(0, T*N, 10000);
d = [0:T:T*N];
y = pulstran(x, d, 'tripuls', D, 0); % el ultimo parametro varia de -1 a 1
plot(x, y, 'LineWidth', 2);
ylim([-1 2])
grid on

%% Animacion (Mantener el Periodo, cambiando el ancho del pulso)


clc
clear
close all
x = linspace(-2, 2, 10000);
d = [-2 -1 0 1 2];
for i=0:0.01:1
y = pulstran(x, d, 'rectpuls', i);
plot(x, y, 'LineWidth', 2); grid on;
ylim([-1 2])
pause(0.005)
end

%% Animacion (Mantener el Periodo, cambiando el ancho del pulso)


clc
clear
close all
T = 10;
N = 10;
D = 8;
f = 1/T;
x = linspace(-2, 2, 10000);
for i=100:-2:0
y = square(2*pi*f*x, i); % Segundo parametro varia entre 0 1 100
% Porcentaje de tiempo en alto
plot(x, y, 'Linewidth', 2);
ylim([-2 2]);
grid on;
pause(0.1)
end

%% Animacion 2 (Mantener el Periodo, cambiando el ancho del pulso)


clc
clear
close all
T = 10;
D = 0.5;
N = 10;
x = linspace(-T*N/2, T*N/2, 10000);
for i=1:2: T*N/2
d = [-T*N/2:i:T*N/2]
y = pulstran(x, d, 'rectpuls', D);
plot(x, y, 'Linewidth', 2);
ylim([-1 2]);
grid on;
pause(0.1)
end

GENERACION DE SEALES SINGULARES


%% Graficas de Funciones Singulares

% Funcion Escalon
clc
clear
close all
t = linspace(-10, 10, 1000);
u1t = heaviside(t); % cambiarlo luego t t-3
plot(t, u1t, 'Linewidth', 2); grid on
title('\bfFUNCION ESCALON')
ylim([-5 5])

% Funcion RAMPA
clc
clear
close all
t = linspace(-10, 10, 1000);
u2t = t.*heaviside(t); % cambiar luego toda t t+4, luego t+4 -t+4
% luego cambiar a t 3*t, primero en las pendiente
plot(t, u2t, 'Linewidth', 2); grid on
title('\bfFUNCION RAMPA')
ylim([-10 10])

% Funcion Parabola
clc
clear
close all
t = linspace(-10, 10, 1000);
u2t = ((t).^2)/2 .*heaviside(t); % cambiarlo luego t t+4
plot(t, u3t, 'k', 'Linewidth', 2); grid on
title('\bfFUNCION PARABOLA')
ylim([-50 50])

%% Otra forma de dibujar estas funciones


clc
clear
close all
t = linspace(-10, 10, 1000);
ut = (t<=0).*0 + (t>0).*(1); % cambiar 0 4 solo en los terminos logicas
plot(t, ut, 'r','Linewidth', 2); grid on
title('\bfOTRA ALTERNATIVA')
ylim([-5 5])
%% Funcion Escalon por una sinusoidal
clc
clear
close all
t = linspace(-20, 20, 1000);
ut = heaviside(t).*sin(t); % cambiar todo t t+4
plot(t, ut, 'Linewidth', 2); grid on
title('\bfFUNCION ESCALON POR UNA SINUSOIDAL')
ylim([-2 2])

close all
clear
clc
t = linspace(0, 4, 100);
p1 = t.*heavislde(t);|
p2 = -(t-1).*heaviside(t-1);
p3 = 2*((t-3).^2)/2.*heaviside(t-3);
ft = p1 + p2 + p3;
plot(t,ft,'Linewidth', 2);
grid on
%%
close all
clear
clc
t = linspace(0, 2*pi, 100);
pi = 10*sin(t).*heaviside(t);
p2 = -10*sin(t).*heaviside(t-pi);
ft = p1 + p2:
plot(t, ft, 'Linewidth', 2);
grid on
ylim([-5 15])

%%
close all
clear
clc
t = linspace(0, 60, 10000);
p1 = 10*sin(t).*heaviside(t);
p2 = -10*sin(t).*heaviside(t-pi);
ft = p1 + p2:
plot(t, ft, 'Linewidth', 2);
grid on
ylim([-5 15])

http://www.youtube.com/watch?v=4W7-bkO8ehM

%%
close all
clear
clc
t = linspace(0, 60, 10000);
p1 = 200*heaviside(t);
p2 = -500*heaviside(t-20);
p3 = 10*heaviside(t-20).*(t-20);
p4 = -10*heaviside(t-20).*(t-40);
p5 = 100*heaviside(t-60);
ft = p1 + p2 + p3 + p4 + p5;
plot(t, ft, 'Linewidth', 2);
grid on
ylim([-400 300])

Anda mungkin juga menyukai