SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

19
%%%%% COSENO %%%%% clear all; t = -2*10^(-6):10^(-9):2*10^(-6); T = 10^(-6); f = 1/T; w = 2*pi*f; fase = pi/4; am = 2; y = am*cos(w*t + fase); plot (t, y, 'b', 'LineWidth', 2); axis ([-1.5e-6, 1.5e-6, -2.5, 2.5]); xlabel ('t (segundos)', 'FontName', 'Times', 'Fontsize', 14); ylabel ('coseno de periodo T', 'FontName', 'Times', 'Fontsize', 14) set (gca, 'FontName', 'Times', 'Fontsize', 12); grid on; set (gca, 'xtick', [-10^(-6) 0 10^(-6)], 'XTickLabel', {'-T'; '0'; 'T'}, 'FontName','Times', 'Fontsize', 12); set (gca, 'ytick', [-2 0 2], 'YTickLabel', {'-A'; '0'; 'A'}); clear all; title ('Función coseno (AAM)', 'FontName', 'Times', 'Fontsize', 24);

Transcript of SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

Page 1: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

%%%%% COSENO %%%%%clear all; t = -2*10^(-6):10^(-9):2*10^(-6);T = 10^(-6); f = 1/T; w = 2*pi*f; fase = pi/4; am = 2; y = am*cos(w*t + fase);plot (t, y, 'b', 'LineWidth', 2); axis ([-1.5e-6, 1.5e-6, -2.5, 2.5]);xlabel ('t (segundos)', 'FontName', 'Times', 'Fontsize', 14);ylabel ('coseno de periodo T', 'FontName', 'Times', 'Fontsize', 14)set (gca, 'FontName', 'Times', 'Fontsize', 12); grid on; set (gca, 'xtick', [-10^(-6) 0 10^(-6)], 'XTickLabel', {'-T'; '0'; 'T'}, 'FontName','Times', 'Fontsize', 12);set (gca, 'ytick', [-2 0 2], 'YTickLabel', {'-A'; '0'; 'A'});clear all; title ('Función coseno (AAM)', 'FontName', 'Times', 'Fontsize', 24);

Page 2: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

%%%%% FUNCIONES EXPONENCIALES %%%%%clear all;t = linspace (-2, 2, 1000);c = -0.5; A = 2; y1 = A*exp(c*t); subplot (2, 2, 1); plot (t, y1, 'b', 'LineWidth', 2); xlabel ('t (segundos)', 'FontName', 'Times', 'Fontsize', 14); ylabel ('A > 0 c < 0', 'FontName', 'Times', 'Fontsize', 14); set (gca, 'FontName', 'Times', 'Fontsize', 12); grid on; axis ([-2, 2, -1, 7]); set (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [0 2], 'YTickLabel', {'0'; 'A'}, 'FontName', 'Times', 'Fontsize',12);title ('Exponenciales decrecientes', 'FontName', 'Times', 'Fontsize', 24)c = 0.5; A = 2; y2 = A*exp(c*t); subplot (2, 2, 2); plot (t, y2, 'b', 'LineWidth', 2); xlabel ('t (segundos)', 'FontName', 'Times', 'Fontsize', 14);ylabel ('A > 0 c > 0', 'FontName', 'Times', 'Fontsize', 14); set (gca, 'FontName', 'Times', 'Fontsize', 12); grid on; axis ([-2, 2, -1, 7]); set (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [0 2], 'YTickLabel', {'0'; 'A'}, 'FontName', 'Times', 'Fontsize',12);title ('Exponenciales crecientes', 'FontName', 'Times', 'Fontsize', 24) c = 0.5; A = -2; y3 = A*exp(c*t);subplot (2, 2, 3);plot (t, y3, 'b', 'LineWidth', 2); xlabel ('t (segundos)', 'FontName', 'Times', 'Fontsize', 14);ylabel ('A < 0 c > 0', 'FontName', 'Times', 'Fontsize', 14);set (gca, 'FontName', 'Times', 'Fontsize', 12);grid on; axis ([-2, 2, -7, 1]); set (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [-2 0], 'YTickLabel', {'A'; '0'}, 'FontName', 'Times', 'Fontsize',12)c = -0.5; A = -2; y3 = A*exp(c*t); subplot (2, 2, 4); plot (t, y3, 'b', 'LineWidth', 2); xlabel ('t (segundos)', 'FontName', 'Times', 'Fontsize', 14); ylabel ('A < 0 c < 0', 'FontName', 'Times', 'Fontsize', 14); set (gca, 'FontName', 'Times', 'Fontsize', 12); grid on; axis ([-2, 2, -7, 1]);

Page 3: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

set (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [-2 0], 'YTickLabel', {'A'; '0'}, 'FontName', 'Times', 'Fontsize',12);clear all; title ('Funciónes exponenciales (AAM)', 'FontName', 'Times', 'Fontsize', 18);

%%%%% FUNCIÓN EXPONENCIAL COMPLEJA (partes real e imaginaria) %%%%%clear all t = -3*10^(-3): 10^(-5): 3*10^(-3) am = 0.5; fase = pi/4; A = am*exp(j*fase); sigma = 0.5*10^3; T = 10^(-3); f = 1/T; w = 2*pi*f; s = sigma + j*w; y = A*exp(s*t); subplot (2, 1, 1); plot (t, real(y), 'b', 'LineWidth', 2); hold on

Page 4: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

plot (t, abs(y), 'r');plot (t, -abs(y), 'r'); xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); ylabel ('Parte real', 'FontName', 'Times', 'Fontsize', 14); grid on; axis ([-2*10^(-3), 2*10^(-3), -3, 3]); set (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [-0.5 0.5], 'YTickLabel', {' -a'; ' a'}, 'FontName', 'Times','Fontsize', 12);title ('Exponencial compleja', 'FontName', 'Times', 'Fontsize', 24) subplot (2, 1, 2); plot (t, imag(y), 'b', 'LineWidth', 2); hold onplot (t, abs(y), 'r'); plot (t, -abs(y), 'r'); xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); ylabel ('Parte imaginaria', 'FontName', 'Times', 'Fontsize', 14); grid on; axis ([-2*10^(-3), 2*10^(-3), -3, 3]); set (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [-0.5 0.5], 'YTickLabel', {' -a'; ' a'}, 'FontName', 'Times','Fontsize', 12);hold off title ('Funciónes exponenciales (AAM)', 'FontName', 'Times', 'Fontsize',18); clear all;

Page 5: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

%%%%% FUNCIÓN EXPONENCIAL COMPLEJA (influencia de los parámetros) %%%%%clear all; % Elimina variables utilizadas en otras rutinast = -3*10^(-3): 10^(-5): 3*10^(-3); % Base de tiemposam = 0.5; % Módulo de la amplitud complejafase = 0; % Fase de la amplitud complejaA = am*exp(j*fase); % Amplitud complejasigma = 0.5*10^3; % Parte real del coeficiente del exponenteT = 10^(-3); % Periodo de la funciónf = 1/T; % Frecuenciaw = 2*pi*f; % Frecuencia angulars = sigma + j*w; % Coeficiente del exponenteenv = A*exp(sigma*t); % Envolvente superiory = A*exp(sigma*t).*cos(w*t + fase);% Funciónsubplot (2, 2, 1); % Recuadro parte realplot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2hold on;plot (t, env, 'r'); % Envolvente de la parte superior (en rojo)plot (t, -env, 'r'); % Envolvente de la parte inferior (en rojo)xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('Parte real (sigma > 0)', 'FontName', 'Times', 'Fontsize', 14); % Ordenadasgrid on; % Mallaaxis ([-2*10^(-3), 2*10^(-3), -3, 3]); % Área de dibujoset (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);

Page 6: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

set (gca, 'ytick', [-0.5 0.5], 'YTickLabel', {' -a'; ' a'}, 'FontName', 'Times','Fontsize', 12);title ('Exponenciales crecientes', 'FontName', 'Times', 'Fontsize', 24) % Títulosigma = -0.5*10^3; % Parte real del coeficiente del exponenteenv = A*exp(sigma*t); % Envolvente superiory = A*exp(sigma*t).*cos(w*t + fase);% Funciónsubplot (2, 2, 2); % Recuadro parte realplot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2hold on;plot (t, env, 'r'); % Envolvente de la parte superior (en rojo)plot (t, -env, 'r'); % Envolvente de la parte inferior (en rojo)xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('Parte real (sigma < 0)', 'FontName', 'Times', 'Fontsize', 14); % Ordenadasgrid on; % Mallaaxis ([-2*10^(-3), 2*10^(-3), -3, 3]); % Área de dibujoset (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [-0.5 0.5], 'YTickLabel', {' -a'; ' a'}, 'FontName', 'Times','Fontsize', 12);title ('Exponenciales amortiguadas', 'FontName', 'Times', 'Fontsize', 24)% Títulosigma = 0.5*10^3; % Parte real del coeficiente del exponenteenv = A*exp(sigma*t); % Envolvente superiory = A*exp(sigma*t).*sin(w*t + fase);% Funciónsubplot (2, 2, 3); % Recuadro parte imaginariaplot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2hold on;plot (t, env, 'r'); % Envolvente de la parte superior (en rojo)plot (t, -env, 'r'); % Envolvente de la parte inferior (en rojo)xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('Parte imaginaria (sigma > 0)', 'FontName', 'Times', 'Fontsize', 14);% Ordgrid on; % Mallaaxis ([-2*10^(-3), 2*10^(-3), -3, 3]); % Área de dibujoset (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [-0.5 0.5], 'YTickLabel', {' -a'; ' a'}, 'FontName', 'Times','Fontsize', 12);sigma = -0.5*10^3; % Parte real del coeficiente del exponenteenv = A*exp(sigma*t); % Envolvente superiory = A*exp(sigma*t).*sin(w*t + fase);% Funciónsubplot (2, 2, 4); % Recuadro parte imaginariaplot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2hold on;plot (t, env, 'r'); % Envolvente de la parte superior (en rojo)plot (t, -env, 'r'); % Envolvente de la parte inferior (en rojo)xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('Parte imaginaria (sigma < 0)', 'FontName', 'Times', 'Fontsize', 14); % Ordgrid on; % Mallaaxis ([-2*10^(-3), 2*10^(-3), -3, 3]); % Área de dibujoset (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [-0.5 0.5], 'YTickLabel', {' -a'; ' a'}, 'FontName', 'Times','Fontsize', 12);

Page 7: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

hold off;title ('Funciónes exponenciales (AAM)', 'FontName', 'Times', 'Fontsize',18);clear all; % Elimina las variables utilizadas en esta rutina

%%%%% FUNCIÓN PULSO RECTANGULAR %%%%%clear all; t = -4: 0.001: 4;y = zeros (1, length(t));A = 1; T = 2; rango = find ((t >= -T/2) & (t <= T/2));y(rango) = A; plot (t, y, 'b', 'LineWidth', 2); xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); ylabel ('Amplitud', 'FontName', 'Times', 'Fontsize', 14); grid on; axis ([-3, 3, -A/2, 2*A]); set (gca, 'xtick', [-T/2 0 T/2], 'XTickLabel', {'-T/2', '0', 'T/2'}, 'FontName','Times', 'Fontsize', 12);set (gca, 'ytick', [0 A], 'YTickLabel', {' 0'; ' A'}, 'FontName', 'Times', 'Fontsize',12);title ('Pulso rectangular(AAM)', 'FontName', 'Times', 'Fontsize', 24) clear all;

Page 8: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

%%%%% FUNCIÓN PULSO TRIANGULAR %%%%%clear all % Elimina variables utilizadas en otras rutinas% Base de tiempostmin = -4;tmax = 4;puntos = 10000;t = linspace (tmin, tmax, puntos);y = zeros (1, length(t)); % Comienza anulando la funciónA = 1; % AmplitudT = 2; % Periodo% Rango de valores de t para los que la función no es nularango = find ((t >= -T/2) & (t <= T/2));y(rango) = A*(1 - abs(t(rango))/(T/2)); % Función en el rango de tiempo no nuloplot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('Amplitud', 'FontName', 'Times', 'Fontsize', 14); % Ordenadasgrid on; % Mallaaxis ([-1.5*T, 1.5*T, -A/2, 2*A]); % Área de dibujoset (gca, 'xtick', [-T/2 0 T/2], 'XTickLabel', {'-T/2', '0', 'T/2'}, 'FontName','Times', 'Fontsize', 12);set (gca, 'ytick', [0 A], 'YTickLabel', {' 0'; ' A'}, 'FontName', 'Times', 'Fontsize',12);

Page 9: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

title ('Pulso triangular(AAM)', 'FontName', 'Times', 'Fontsize', 24) % Títuloclear all; % Elimina las variables utilizadas en esta rutina

%%%%% FUNCIÓN ESCALÓN %%%%%clear all; % Elimina variables utilizadas en otras rutinas% Base de tiempostmin = -4;tmax = 4;puntos = 1000;t = tmin: 1/puntos: tmax;y = zeros (1, length(t)); % Comienza anulando la funciónA = 1; % Amplitudtitle ('FUNCION ESCALON(NSVD)', 'FontName', 'Times', 'Fontsize', 24);T = 2; % Tiempo de discontinuidad% Rango de valores de t para los que la función no es nularango = find (t >= T);y(rango) = A; % Valor de la función en el rango de tiempo no nulosubplot (2, 2, 1);plot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('T > 0', 'FontName', 'Times', 'Fontsize', 14);% Ordenadasgrid on; % Malla

Page 10: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

axis ([-1.5*abs(T), 1.5*abs(T), -A/2, 2*A]); % Área de dibujoset (gca, 'xtick', [0 T], 'XTickLabel', {'0', 'T'}, 'FontName', 'Times', 'Fontsize',12);set (gca, 'ytick', [0 A], 'YTickLabel', {' 0'; ' A'}, 'FontName', 'Times', 'Fontsize',12);title ('Escalón u(t - T)', 'FontName', 'Times', 'Fontsize', 24); % Títuloy = zeros (1, length(t)); % Comienza anulando la funciónA = 1; % AmplitudT = -2; % Tiempo de discontinuidad% Rango de valores de t para los que la función no es nularango = find (t >= T);y(rango) = A; % Valor de la función en el rango de tiempo no nulosubplot (2, 2, 3);plot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('T < 0', 'FontName', 'Times', 'Fontsize', 14);% Ordenadasgrid on; % Mallaaxis ([-1.5*abs(T), 1.5*abs(T), -A/2, 2*A]); % Área de dibujoset (gca, 'xtick', [T 0], 'XTickLabel', {'T', '0'}, 'FontName', 'Times', 'Fontsize',12);set (gca, 'ytick', [0 A], 'YTickLabel', {' 0'; ' A'}, 'FontName', 'Times', 'Fontsize',12);y = zeros (1, length(t)); % Comienza anulando la funciónA = 1; % AmplitudT = 2; % Tiempo de discontinuidad% Rango de valores de t para los que la función no es nularango = find (t <= T);y(rango) = A; % Valor de la función en el rango de tiempo no nulosubplot (2, 2, 2);plot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('T > 0', 'FontName', 'Times', 'Fontsize', 14) % Ordenadasgrid on; % Mallaaxis ([-1.5*abs(T), 1.5*abs(T), -A/2, 2*A]); % Área de dibujoset (gca, 'xtick', [0 T], 'XTickLabel', {'0', 'T'}, 'FontName', 'Times', 'Fontsize',12);set (gca, 'ytick', [0 A], 'YTickLabel', {' 0'; ' A'}, 'FontName', 'Times', 'Fontsize',12);title ('Escalón u(T - t)', 'FontName', 'Times', 'Fontsize', 24); % Títuloy = zeros (1, length(t)); % Comienza anulando la funciónA = 1; % AmplitudT = -2; % Tiempo de discontinuidad% Rango de valores de t para los que la función no es nularango = find (t <= T);y(rango) = A; % Valor de la función en el rango de tiempo no nulosubplot (2, 2, 4);plot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('T < 0', 'FontName', 'Time & Ordenadas');grid on; % Mallaaxis ([-1.5*abs(T), 1.5*abs(T), -A/2, 2*A]); % Área de dibujoset (gca, 'xtick', [T 0], 'XTickLabel', {'T', '0'}, 'FontName', 'Times', 'Fontsize',12);set (gca, 'ytick', [0 A], 'YTickLabel', {' 0'; ' A'}, 'FontName', 'Times', 'Fontsize',12);title ('FUNCION ESCALON(AAM)', 'FontName', 'Times', 'Fontsize', 24)clear all; % Elimina las variables utilizadas en esta rutina

Page 11: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

%%%%% FUNCIÓN SIGNO %%%%%clear all; % Elimina variables utilizadas en otras rutinas% Base de tiempostmin = -4;tmax = 4;puntos = 10000;t = linspace (tmin, tmax, puntos);A = 1;y = A*sign(t); % Funciónplot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('Amplitud', 'FontName', 'Times', 'Fontsize', 14); % Ordenadasgrid on; % Mallaaxis ([(3/4)*tmin, (3/4)*tmax, -2*A, 2*A]); % Área de dibujoset (gca, 'xtick', [0], 'XTickLabel', {'0'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [-A 0 A], 'YTickLabel', {' -A'; ' 0'; ' A'}, 'FontName', 'Times','Fontsize', 12);title ('Función signo (AAM)', 'FontName', 'Times', 'Fontsize', 24); % Títuloclear all; % Elimina las variables utilizadas en esta rutina

Page 12: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

%%%funcion sincclear all; % Elimina variables utilizadas en otras rutinas

% Base de tiempostmin = -8;tmax = 8;puntos = 10000;t = linspace (tmin, tmax, puntos);A = 1;y = A*sinc(t);plot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('Amplitud', 'FontName', 'Times', 'Fontsize', 14); % Ordenadasgrid on; % Mallaaxis ([tmin, tmax, -(1/2)*A, (5/4)*A]); % Área de dibujo%set (gca, 'ytick', [0 A], 'YTickLabel', {' 0'; ' A'}, 'FontName', 'Times', 'Font-size', 12);title ('Funcion sinc (AAM)', 'FontName', 'Times', 'Fontsize', 24); % Título%clear all; % Elimina las variables utilizadas en esta rutina

Page 13: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

%%%%% TREN DE PULSOS RECTANGULARES %%%%%clear all; % Elimina variables utilizadas en otras rutinasA = 1; % AmplitudP = 2; % Duración del pulsoT = 6; % Periodotmin = -7*P; % Base de tiempostmax = 7*P;puntos = 10000;t = linspace (tmin, tmax, puntos);y = zeros (1, length(t)); % Anula la funciónn = 0; % Número de periodos para t < 0while n*T>tminn = n - 1;endtc1 = (n: 0)*T; % Instantes centrales de los pulsosm = 1; % Número de periodos para t > 0while m*T<tmaxm = m + 1;endtc2 = (0: m)*T; % Instantes centrales de los pulsostc = [tc1 tc2]; % Instantes centrales de todos los pulsosk = 1; % Amplitud de cada pulso

Page 14: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

while k<=length(tc)rango = find((t >= tc(k) - P/2) & (t <= tc(k) + P/2));y(rango) = A;k = k + 1;endplot (t, y, 'b', 'LineWidth', 2); % Curva en azul de grosor 2xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('Amplitud', 'FontName', 'Times', 'Fontsize', 14); % Ordenadasgrid on; % Mallaaxis ([tmin, tmax, -A/3, (3/2)*A]); % Área de dibujoset (gca, 'xtick', [-T/2 -P/2 0 P/2 T/2], 'XTickLabel', {'-T/2'; '-P/2'; '0'; 'P/2';'T/2'}, 'FontName', 'Times', 'Fontsize', 12);set (gca, 'ytick', [0 A], 'YTickLabel', {' 0'; ' A'}, 'FontName', 'Times', 'Fontsize',12);title ('Tren de pulsos rectangulares(AAM)', 'FontName', 'Times', 'Fontsize', 24);% Títuloclear all; % Elimina las variables utilizadas en esta rutina

Page 15: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

function x = natitascomb(t)n = length(t);x = zeros(1,n);i = t < 0;x(i)=0;i = find(t > 0 & t < 1);x(i) = 1 - exp (-t(i)); % Primera funcióni = find(t >= 1);x(i) = -exp(-t(i)) + exp(-t(i) + 1); % Segunda funciónreturn; %%%%% FUNCIÓN COMBINADA %%%%%clear all; % Elimina variables utilizadas en otras rutinasT1 = 0; % Comienzo de la primera funciónT2 = 1; % Comienzo de la segunda función% Base de tiempostmin = -3;tmax = 3;puntos = 1000;t = linspace(tmin, tmax, puntos);y = natitascomb(t); % Llama a la función combinadaplot (t, y, 'b', 'LineWidth', 2);% Curva en azul de grosor 2xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('Amplitud', 'FontName', 'Times', 'Fontsize', 14); % Ordenadasgrid on; % Mallaaxis ([(3/4)*tmin, (3/4)*tmax, -(1/3)*max(y), (3/2)*max(y)]); % Área de dibujoset (gca, 'xtick', [T1 T2], 'XTickLabel', {'T1'; 'T2'}, 'FontName', 'Times', 'Fontsize',12);set (gca, 'ytick', [0], 'YTickLabel', {' 0'}, 'FontName', 'Times', 'Fontsize', 12);title ('Función combinada (AAM)', 'FontName', 'Times', 'Fontsize', 24); % Títuloclear all; % Elimina las variables utilizadas en esta rutina

Page 16: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

%%%%% PARTES PAR E IMPAR DE UNA FUNCIÓN %%%%%clear all; % Elimina variables utilizadas en otras rutinasT1 = 0; % Comienzo de la primera funciónT2 = 1; % Comienzo de la segunda función% Base de tiempostmin = -3;tmax = 3;puntos = 1000;t = linspace(tmin, tmax, puntos);y = funccomb(t) + 0.02; % Función originalplot (t, y, 'k'); % Función en negrohold on;xlabel ('t', 'FontName', 'Times', 'Fontsize', 14); % Abscisasylabel ('Función (negro), Par (rojo), Impar (verde), Suma (azul)', 'FontName', 'Times','Fontsize', 14); % Ordenadasgrid on; % Mallaaxis ([(3/4)*tmin, (3/4)*tmax, -(2/3)*max(y), (3/2)*max(y)]); % Área de dibujoset (gca, 'xtick', [T1 T2], 'XTickLabel', {'T1'; 'T2'}, 'FontName', 'Times', 'Fontsize',12);set (gca, 'ytick', [0], 'YTickLabel', {' 0'}, 'FontName', 'Times', 'Fontsize', 12);

Page 17: SEÑALES Y SISTEMAS MATLAB AURELIO ALEMAN MINOR

tt = -t;yy = funccomb(tt);ypar = 0.005 + (y + yy)/2; % Parte parplot (t, ypar, 'r');hold on;yimpar = (y - yy)/2 - 0.005; % Parte imparplot (t, yimpar, 'g');hold on;ytotal = ypar + yimpar - 0.02;plot (t, ytotal, 'b', 'Linewidth', 2); % Suma en azul de grosor 2hold off;title ('Partes par e impar de una función (AAM)', 'FontName', 'Times', 'Fontsize', 24);% Títuloclear all; % Elimina las variables utilizadas en esta rutina