clc
function [y]=impulso(x)
y=zeros(1,length(x));
y(find(x==0))=1;
endfunction
x=0
n=-10:1:10
amplitude=[0,0,0,1,3,7,9,14,0,6,0,0,0,0,0,0,0,0,0,0,18]
//amplitude(4)
contador=1;
while contador <> 21
x=x+ amplitude(contador)*impulso(n+11-contador)
contador=contador+1;
end
plot2d3(n,x)
clc
function [y]=impulso(x)
y=zeros(1,length(x));
y(find(x==0))=1;
endfunction
x=0:1:100
h=0
n=-50:1:50
//amplitude=[0,0,0,1,3,7,9,14,0,6,0,0,0,0,0,0,0,0,0,0,18]
//amplitude(4)
amplitude=sin(2*%pi*x)
contador=1;
while contador <> 101
h=h+ amplitude(contador)*impulso(n+51-contador)
contador=contador+1;
end
plot2d3(n,h)
----------------------------------------------------------------------
--------------------------------------------------------clc
///funcao transformacao da variavel independente
///exemplo y=transformacao(x,1,-2) para x[n-2] y=tranforma(x,-1,0) para x(-n)etc
function [res]=transformacontinuo(x, n, numero)//ondex é o valor com pulsos, n é o numero 1 para o proprio n -1
para espelhar n ou outro numero para multiplicar n
clc;
clf;
p=-10:10;
res=zeros(1,length(x));
aux=length(x) + numero; //adiciona ou subitraipra poder terminar antes de achar o valor
for i=1: length(x)
if(((i + numero)>=1) & ((i + numero) <=length(x))) then
res (i)=x(i + numero);
else
res(i)=0;
end
end
res2=zeros(1,length(x));
if n<0 then
for i=1:length(x)
//inverte espelha
res2(i)=res(length(x)+1-i);
end
res=res2;
end
// comprime 2n 3n etc
res2=zeros(1,length(x));
if n > 1 then
for i=-10:10 //-10-9-8-7-6 para fazer a multiplicação certo
if((i*n)+11<21) & ((i*n)+11 >=1) then // teste se i >= 1 ou <=20 pra não estourar o index do valor que vai de
1 a20
res2(i+11)=res((i*n)+11);
end
end
res=res2;
end
// expande n/2 n/3 etc usar 0.5 para n/2
res=zeros(1,length(x));
if n > 0 & n < 1 then
for i=-10:10 //-9-8-7-6 para fazer a multiplicação certo
if ((i*n)+11 <21) & ((i*n)+11>=1 & ((i*n)==int(i*n)) then // teste se i >=1 ou pra não estourar o idex do vetor
de 1 a 20
res2(i+11)=res((i*n)+11);
end
end
res=res2;
end
subplut(211)
plot2d3(p,x)
subplot(212)
plot2d3(p,res)
endfunction
//Função transformação da variável independente
//Exemplo y=transforma(x,1,-2) para x([n-2] y=transforma(x,-1,0) para
x[-n] etc
function [res]=transformacontinuo(x,n,numero) //Onde "x" é o vetor com
os pulsos, "n" é o número para espelhar "n" ou outros números para
mutiplicar "n"
clc;
clf;
p=-10:10;
res=zeros(1, length(x));
aux=length(x) + numero; //Adiciona ou subtrai para poder terminar
antes de achar o vetor
for i=1: length(x)
if (((i + numero) >= 1) & ((i + numero) <= length (x))) then
res(i)=x(i+numero);
else
res(i)=0;
end
end
res2=zeros(1, length(x));
if n < 0 then
for i=1: length(x)
//Inverte espelha
res2(i)=res(length(x)+1-i);
end
res=res2;
end
//Expande n/2 n/3 etc usar 0.5 para n/2
res2=zeros(1, length(x));
if n > 1 then
for i=-10:10 // -10 -9 -8 -7 -6 para fazer a multiplicação
if((i*n)+11 < 21) & ((i*n)+11 >=1) then //Teste se i>= 1 ou <=
20 para não estourar o index do vetor que vai de 1 a 20
res2(i+11)=res((i*n)+11);
end
end
res=res2;
end
//Expande n/2 n/3 etc usar 0.5 para n/2
res2=zeros(1,length(x));
if n > 0 then
for i=-10:10 //-10 -9 -8 -7 -6 para fazer a multiplicação certo
if((i*n)+11 < 21) & ((i*n)+11 >=1) & ((i*n)==int(i*n)) then
res2(i+11)=res((i*n)+11);
end
end
res=res2;
end
subplot(211)
plot2d3(p,x)
subplot(212)
plot2d3(p,res)
endfunction