Señal de tiempo discreto

Señal de tiempo discreto

clc, clear all, close all

 

disp(‘Variable independiente -tiempo (nx = nxi:nxf) para la señal x(n)’);

nx=input(‘nxi:nxf :  ‘);

 

disp(‘Ingrese las muestras de la señal x(n)’);

x=input(‘Utilizar corchetes [x(nxi) … x(nxf)]: ‘);

 

xdn=sx(nx,x);

 

figure, stem(nx,xdn,‘LineWidth’,2),

axis([min(nx)-1,max(nx)+1,min(xdn)-2,max(xdn)+2]);

xlabel(‘n’); ylabel(‘x(n)’); title(‘Señal x(n)’);

ntick = [nx(1):nx(length(nx))];

set(gca,‘XtickMode’,‘manual’,‘XTick’,ntick,‘FontSize’,10)

 

% Señal x(n) expresada con la función delta(n)

function y=sx(nx,x),

y=zeros(1,length(nx));

 for k=1:length(x);

     y = y + x(k)*delta(nx-nx(k));

 end

end

 

function y=delta(n),

y = 1.*(n==0);

end

Nota. Cambiar la comilla simple por apóstrofe en la hoja de editor de Matlab.

Ejemplo. Graficar la señal de tiempo discreto: x(n)=[-2.5, 0.5, 1*, -1.5, 0.5, 2.5].

Solución:
Se ingresan los siguientes datos:
Valores para la variable independiente -tiempo (nx = nxi:nxf) para la señal x(n)
nxi:nxf : -2:3
Ingrese las muestras de la señal x(n)
Utilizar corchetes [x(nxi) … x(nxf)]: [-2.5 0.5 1 -1.5 0.5 2.5]

No Comments Yet.