You are on page 1of 5

LABORATORIO 02:

x=-1:6

y= [1 2 3 4 5 6 7 8]

N= 3

DESPLAZA
function [a,b] = desplaza( x,y,N)
a= x+N;
b=y;
subplot(2,1,1); stem(x,y)
subplot(2,1,2); stem(a,b)
end

REFLEJA
function [a2,b2] = refleja( x,y)
a2=-fliplr(x);
b2=fliplr(y);
subplot(2,1,1); stem(x,y)
subplot(2,1,2); stem(a2,b2)
end

COMPRIME
function [a3,b3] = comprime( x,y,p)
k=0;
for i=x(1): x(length(x))
k=k+1;
if mod(i,p)==0
a3(k)=i/p;
b3(k)=y(k);
end
end
subplot(2,1,1); stem(x,y)
subplot(2,1,2); stem(a3,b3)
end

DILATA
function [a4,b4] = dilata( x,y,p)
m=x*p;
f=m(1):m(length(m));
k=0;
j=0;
for i=f(1):f(length(f))
k=k+1;
if mod(i,p)==0
j=j+1;
a4(k)=f(k);
b4(k)=y(j);
else
a4(k)=f(k);
b4(k)= 0;
end
end
subplot(2,1,1); stem(x,y)
subplot(2,1,2); stem(a4,b4)
end

You might also like