Escolar Documentos
Profissional Documentos
Cultura Documentos
de
Códigos de Programas Demonstrativos
para
Fundamentos de
Processamento Digital de Sinais
(Versão A2022M03D09)
Março – 2022
.
iii
Prefácio
v
vi
Agradecimentos
vii
viii
Apresentação do material didático
• Pelo contrário, ele nasceu, evoluiu e tem sido mantido de uma forma bem orgânica.
• Na época do seu ingresso, o Processamento Digital de Sinais já era um assunto presente
na área de Telecomunicações. E com importância crescente. Apesar disso, ainda não era
oferecida pelo TET uma disciplina formal sobre a matemática que o fundamenta.
• Com essa percepção, ele criou a disciplina optativa “Introdução ao Processamento Digital
de Sinais”, em 1998.
• Para dar suporte às aulas, foram elaboradas as primeiras notas de aula (manuscritas)
para a disciplina optativa criada no TET. Nessa primeira tentativa de implantação da
disciplina, foi usada a referência [Mit98] como livro texto.
• A disciplina optativa foi oferecida pelo autor apenas durante dois perı́odos letivos, em
virtude do seu afastamento para finalização do seu doutoramento.
• Durante o afastamento, e mesmo algum tempo depois, a disciplina optativa foi oferecida
por outro professor do TET. Nesse perı́odo, o autor lançou uma outra disciplina optativa,
vinculada à primeira, tratando do Projeto de Filtros Digitais.
• Na primeira década de 2000, o TET realizou uma reforma curricular e a disciplina optativa
“Introdução ao Processamento Digital de Sinais” tornou-se obrigatória, sob o nome de
“Processamento Digital de Sinais”.
• Tendo voltado a ministrar a disciplina, o autor decidiu ampliar as notas de aula manus-
critas, baseando-se em diversos outros livros.
ix
x
• A partir daı́, com a maturação gradual que a disciplina foi ganhando a cada perı́odo letivo,
novos conteúdos foram surgindo. Ora por curiosidade do autor, procurando incorporar
um determinado tópico na disciplina. Ora por curiosidade dos alunos, por demandarem
algum assunto em especial. Ora por necessidade pedagógica, pois, ao se perceberem
dúvidas recorrentes dos alunos, novas formas de abordagem têm sido testadas.
• Além disso, como filosofia educacional do autor, as questões que fazem parte de toda e
qualquer forma de avaliação formal da disciplina (testes, provas, trabalhos) são anexadas
ao conteúdo, na forma de exercı́cios propostos.
• Também como filosofia educacional do autor, a apostila de teoria não apresenta figuras
que ilustrem os assuntos abordados. Pelo contrário, é demandado aos alunos que eles
gerem as suas próprias figuras, a partir de um aplicativo computacional adequado.
• No final da década de 2010, o TET realizou uma nova reforma curricular, a qual acarretou
uma redução na quantidade e na carga horária das disciplinas. Isso provocou uma
reformulação na abordagem dos tópicos da disciplina, que passou a ser denominada de
“Fundamentos de Processamento Digital de Sinais”.
• Em 2018, foi percebido que, utilizando o sistema de média móvel como exemplo, é possı́vel
abordar e integrar os tópicos de interesse da disciplina de forma simples e direta. Além
disso, com ele, também é possı́vel gerar exemplos, exercı́cios e aplicações práticas, com
certa facilidade. Assim, teve inı́cio a elaboração do tutorial sobre o sistema de média
móvel.
• Dessa forma, desde o inı́cio da sua confecção até o presente momento, sempre foram
preparadas diversas versões de cada documento ao longo de um mesmo perı́odo letivo.
Por essa razão, o identificador “Versão A<ano>M<mês>D<dia>” aparece logo abaixo
do tı́tulo de cada apostila.
• No ponto de vista estrutural é que o aspecto dinâmico dos documentos mais se tem feito
presente. Os mais diversos seccionamentos de texto (capı́tulos, seções, subseções, etc.)
surgem, são mesclados e desaparecem, a cada nova versão.
• Por tudo isso, pode-se asseguradamente dizer que todo o material produzido encontra-se
em constante atualização.
xi
– Resposta ao impulso.
– Equação de diferença.
– Diagramas de blocos de complexidade genérica.
– Diagramas de sistema (ou estruturas ou realizações).
– Operador de transferência.
– Diagrama de pólos e zeros do operador de transferência.
– Equações de estado.
– Relações e mapeamentos entre as diversas representações.
xiii
xiv
• Trabalhar com sinais básicos que sejam simultaneamente dependentes das variáveis tempo
e frequência, utilizando-os na composição dos demais sinais envolvidos.
xv
xvi
Sumário
Prefácio v
Agradecimentos vii
Objetivos da disciplina xv
Sumário xvii
I Introdução 1
1 Ambiente de simulação matemática 3
1.1 Introdução . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Aspectos gerais sobre o ambiente . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.1 Definições . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.2 Interação com usuário . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.3 Interpretador de comandos . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.4 Namespace e workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.5 Tipos de dados . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.6 Estruturas de dados . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.7 Funções básicas dedicadas a matrizes . . . . . . . . . . . . . . . . . . . . 6
1.2.8 Códigos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3 Representação gráfica bidimensional (curvas) . . . . . . . . . . . . . . . . . . . . 25
1.3.1 Representação gráfica discreta de função unidimensional . . . . . . . . . 25
1.3.2 Representação gráfica contı́nua de função unidimensional . . . . . . . . . 25
1.3.3 Funções comumente utilizadas . . . . . . . . . . . . . . . . . . . . . . . . 25
1.3.4 Códigos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.4 Representação gráfica tridimensional
(curvas e superfı́cies) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
1.4.1 Representação gráfica discreta de função bidimensional . . . . . . . . . . 33
1.4.2 Representação gráfica contı́nua de função bidimensional . . . . . . . . . . 33
1.4.3 Funções comumente utilizadas . . . . . . . . . . . . . . . . . . . . . . . . 33
1.4.4 Códigos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
1.5 Representação gráfica tridimensional (imagens) . . . . . . . . . . . . . . . . . . 40
1.5.1 Representação gráfica discreta de função bidimensional . . . . . . . . . . 40
1.5.2 Representações de imagens no aplicativo . . . . . . . . . . . . . . . . . . 40
xvii
xviii
2 Conceitos básicos 55
2.1 Introdução . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.2 Tipos de sinais . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.3 Amostragem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
2.4 Arquitetura de sistemas de processamento digital . . . . . . . . . . . . . . . . . 74
Introdução
1
Capı́tulo 1
1.1 Introdução
Neste capı́tulo, são apresentados alguns conceitos básicos relativos ao ambiente de simula-
ção matemática utilizado. São abordados os seguintes itens: aspectos gerais sobre o ambiente
(definições; interação com usuário; interpretador de comandos; namespace e workspace; tipos
de dados; estruturas de dados; comandos e funções comumente utilizados; ações tı́picas de
criação/acesso/operações relativas a estruturas de dados), representação gráfica bidimensio-
nal (curvas), representação gráfica tridimensional (curvas e superfı́cies), representação gráfica
tridimensional (imagens), simulação de equação de diferença.
• O Octave pode ser interpretado como uma máquina computacional virtual, que entende
uma linguagem própria e a traduz para uma outra linguagem, que é entendida por uma
outra máquina computacional, hierarquicamente abaixo dela.
• O Octave trabalha com uma linguagem imperativa. A tradução realizada é uma interpre-
tação. Assim, cada comando da linguagem representa uma assertiva especı́fica, que deve
ser dinamicamente traduzida e executada.
• Um conjunto composto por comandos que sejam reconhecidos pelo aplicativo é denomi-
nado de programa ou código.
3
4 Capı́tulo 1. Ambiente de simulação matemática
• A linguagem reconhecida pelo Octave é do tipo case sensitive, o que significa que identi-
ficadores similares, porém com letras minúsculas ou maiúsculas, são considerados identi-
ficadores diferentes.
• Um conjunto de comandos que é muitas vezes utilizado por um programa e/ou é compar-
tilhado por diversos programas pode ser organizado em uma função. Do ponto de vista
do usuário, uma função é, basicamente, um script com uma sintaxe especı́fica.
• As estruturas de dados em Octave são dinamicamente tipadas. Não se faz necessária uma
declaração antecipada, para a definição de tipo da estrutura e para a reserva de espaço
em memória. Basta um simples comando de construção (construtor) ou uma simples
atribuição de valores, em tempo de execução, para criá-las ou modificá-las.
• Alguns comandos ecoam seu resultado para a janela do interpretador de comandos. Para
evitar esse eco, basta adicionar o caractere ’;’ ao final do comando.
• Caso uma expressão seja avaliada sem uma atribuição explı́cita, a variável padrão ’ans’
(answer ou resposta) recebe o resultado da avaliação.
• Comentários (texto não traduzido) podem ser gerados com o auxı́lio do caractere ’%’,
dado que, a partir dele, tudo é ignorado até o final da linha de comando.
• Caso um comando seja muito longo, ele pode ser quebrado em várias linhas, adicionando-
se reticências (três pontos sem espaço entre eles) ao final de cada linha. Cabe ressaltar
que um comentário de linha não pode ser quebrado e continuado.
A.S.V.
1.2. Aspectos gerais sobre o ambiente 5
• Uma linha de código pode conter vários comandos, que devem ser separados por um
dos seguintes caracteres: ’,’ e ’;’. Como citado anteriormente, resultados de comandos
terminados com ’;’ não são ecoados. Podem ser inseridos espaços antes e depois dos
caracteres de separação.
• O Octave possui o seu próprio namespace, onde são definidos variáveis e valores padrões.
Por exemplo: a unidade imaginária (i ou j) e os números ’e=2.7183...’ e ’pi=3.1416...’.
• Dessa forma, é possı́vel definir novas variáveis e novos valores, diferentes daqueles definidos
pelo Octave, utilizando os mesmos identificadores, mas sem destruir os objetos originais.
• Porém, deve ficar claro que, ao se criar novos objetos no ambiente de trabalho, com os
mesmos identificadores originais, apenas os novos objetos serão acessados. Para voltar a
acessar os objetos padrões, devem-se destruir os objetos definidos no ambiente (utilizando
o comando ’clear’).
TET / UFF
6 Capı́tulo 1. Ambiente de simulação matemática
A.S.V.
1.2. Aspectos gerais sobre o ambiente 7
1.2.8 Códigos
• O Código 1.1 apresenta diversos exemplos de criação de estruturas de dados.
7
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9 % %
% Titulo : %
11 % Exemplos de c r i a c a o de e s t r u t u r a s de dados %
% %
13 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
15 % Datas : /2022−01/ %
% %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
% l i m p e z a do ambiente de t r a b a l h o
21 %
clear all
23 c l o s e a l l
25
disp ( ’ ’)
27 disp ( ’ ’)
disp ( ’ ==========================================’ )
29 disp ( ’ Exemplos de c r i a ç ã o de e s t r u t u r a s de dados ’ )
disp ( ’ ==========================================’ )
31 disp ( ’ ’)
33
%
35 % Exemplos de e s c a l a r ( m a t r i z 1 x1 )
%
37
disp ( ’ ’ )
39 d i s p ( ’ ’ )
disp ( ’ ================================’ )
41 d i s p ( ’ Exemplos de e s c a l a r ( m a t r i z 1 x1 ) ’ )
disp ( ’ ================================’ )
43 d i s p ( ’ ’ )
45 v = ’a ’
47 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
49 pause ( )
TET / UFF
8 Capı́tulo 1. Ambiente de simulação matemática
51 v = 4
53 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
55 pause ( )
57 v = −8.5
59 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
61 pause ( )
63 v = 3 + i *7
65 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
67 pause ( )
69
%
71 % Exemplos de v e t o r l i n h a ( m a t r i z 1xC )
%
73
disp ( ’ ’ )
75 d i s p ( ’ ’ )
disp ( ’ ====================================’ )
77 d i s p ( ’ Exemplos de v e t o r l i n h a ( m a t r i z 1xC) ’ )
disp ( ’ ====================================’ )
79 d i s p ( ’ ’ )
81 v = ’ abc ’
83 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
85 pause ( )
87 v = [ 4 12 1 0 0 ]
89 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
91 pause ( )
93 v = [ −8.5 , 4 , 1 1 . 3 ]
95 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
97 pause ( )
99 v = [ 3 + i * 7 , −2 + i * 9 , i * 1 1 ]
101 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
103 pause ( )
105 v = 5:11
107 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
A.S.V.
1.2. Aspectos gerais sobre o ambiente 9
109 pause ( )
111 v = 12:3:22
113 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
115 pause ( )
119 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
121 pause ( )
123
%
125 % Exemplos de v e t o r c o l u n a ( m a t r i z Lx1 )
%
127
disp ( ’ ’ )
129 d i s p ( ’ ’ )
disp ( ’ =====================================’ )
131 d i s p ( ’ Exemplos de v e t o r c o l u n a ( m a t r i z Lx1 ) ’ )
disp ( ’ =====================================’ )
133 d i s p ( ’ ’ )
135 v = [ ’a ’ ; ’b ’ ; ’ c ’ ]
137 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
139 pause ( )
141 v = [ 4 ; 12 ; 1 0 0 ]
143 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
145 pause ( )
147 v = [ −8.5 ; 4 ; 1 1 . 3 ]
149 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
151 pause ( )
153 v = [ 3 + i * 7 ; −2 + i * 9 ; i * 1 1 ]
155 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
157 pause ( )
159 v = [5:11] ’
161 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
163 pause ( )
165 v = [12:3:22] ’
167 disp ( ’ ’ )
TET / UFF
10 Capı́tulo 1. Ambiente de simulação matemática
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
169 pause ( )
173 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
175 pause ( )
177
%
179 % Exemplos de m a t r i z r e t a n g u l a r ( m a t r i z LxC)
%
181
disp ( ’ ’ )
183 d i s p ( ’ ’ )
disp ( ’ ==========================================’ )
185 d i s p ( ’ Exemplos de m a t r i z r e t a n g u l a r ( m a t r i z LxC) ’ )
disp ( ’ ==========================================’ )
187 d i s p ( ’ ’ )
189 v = [ ’ abcd ’ ; ’ e f g h ’ ]
191 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
193 pause ( )
195 v = [ ’ ab ’ ; ’ cd ’ ; ’ e f ’ ; ’ gh ’ ]
197 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
199 pause ( )
201 v = [ 4 12 100 1 ; 7 11 15 3 ]
203 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
205 pause ( )
207 v = [ 4 12 ; 100 1 ; 7 11 ; 15 3 ]
209 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
211 pause ( )
215 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
217 pause ( )
219
%
221 % Exemplos de m a t r i z quadrada M ( m a t r i z MxM)
%
223
disp ( ’ ’ )
225 d i s p ( ’ ’ )
disp ( ’ ==========================================’ )
A.S.V.
1.2. Aspectos gerais sobre o ambiente 11
233 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
235 pause ( )
237 v = [ 4 12 100 1 ; 7 11 15 3 ; 2 6 19 33 ; 8 10 44 5 6 ]
239 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
241 pause ( )
245 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
247 pause ( )
249
%
251 % Exemplos de c e l l a r r a y
%
253
disp ( ’ ’ )
255 d i s p ( ’ ’ )
disp ( ’ ======================’ )
257 d i s p ( ’ Exemplos de c e l l a r r a y ’ )
disp ( ’ ======================’ )
259 d i s p ( ’ ’ )
261 %
% Constru ç ão com a t r i b u i ç ão
263 %
265 disp ( ’ ’)
disp ( ’ ’)
267 disp ( ’ =========================’ )
disp ( ’ Constru ç ã o com a t r i b u i ç ã o ’ )
269 disp ( ’ =========================’ )
disp ( ’ ’)
271
v = { 1 , [2 , 3] ;
273 [ 4 ; 5 ] , [ 6 , 7 ; 8 , 9 ; 10 , 1 1 ]
}
275
disp ( ’ ’ )
277 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
279
v {1 ,1}
281
disp ( ’ ’ )
283 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
285
TET / UFF
12 Capı́tulo 1. Ambiente de simulação matemática
v {1 ,2}
287
disp ( ’ ’ )
289 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
291
v {2 ,1}
293
disp ( ’ ’ )
295 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
297
v {2 ,2}
299
disp ( ’ ’ )
301 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
303
%
305 % Constru ç ão com fun ç ão
%
307
disp ( ’ ’ )
309 d i s p ( ’ ’ )
d i s p ( ’ =====================’ )
311 d i s p ( ’ Constru ç ã o com fun ç ã o ’ )
d i s p ( ’ =====================’ )
313 d i s p ( ’ ’ )
315 v = c e l l (3 ,2)
317 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
319 pause ( )
A.S.V.
1.2. Aspectos gerais sobre o ambiente 13
345
disp ( ’ ’ )
347 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
349
v {2 ,2}
351
disp ( ’ ’ )
353 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
355
v {3 ,1}
357
disp ( ’ ’ )
359 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
361
v {3 ,2}
363
disp ( ’ ’ )
365 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
367
369 %
% Exemplos de s t r u c t u r e a r r a y
371 %
373 disp ( ’ ’)
disp ( ’ ’)
375 disp ( ’ ===========================’ )
disp ( ’ Exemplos de s t r u c t u r e a r r a y ’ )
377 disp ( ’ ===========================’ )
disp ( ’ ’)
379
%
381 % Constru ç ão com a t r i b u i ç ão
%
383
disp ( ’ ’ )
385 d i s p ( ’ ’ )
d i s p ( ’ =========================’ )
387 d i s p ( ’ Constru ç ã o com a t r i b u i ç ã o ’ )
d i s p ( ’ =========================’ )
389 d i s p ( ’ ’ )
391 %
clear v
393
v . nome = ’ Aluno 1 ’ ;
395 v . n o t a s = [1 .1 2.1 3 . 1 ] ;
v . s i t u a c a o = ’ Reprovado ’
397
disp ( ’ ’ )
399 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
401
v ( 2 ) . nome = ’ Aluno 11 ’ ;
403 v ( 2 ) . n o t a s = [4.1 5.1 6 . 1 ] ;
TET / UFF
14 Capı́tulo 1. Ambiente de simulação matemática
v ( 2 ) . s i t u a c a o = ’VS ’
405
disp ( ’ ’ )
407 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
409
v ( 3 ) . nome = ’ Aluno 111 ’ ;
411 v ( 3 ) . notas = [7.1 8.1 9 . 1 ] ;
v ( 3 ) . s i t u a c a o = ’ Aprovado ’
413
disp ( ’ ’ )
415 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
417
v(1)
419
disp ( ’ ’ )
421 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
423
v(2)
425
disp ( ’ ’ )
427 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
429
v(3)
431
disp ( ’ ’ )
433 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
435
%
437 % Constru ç ão com fun ç ão
%
439
disp ( ’ ’ )
441 d i s p ( ’ ’ )
d i s p ( ’ =====================’ )
443 d i s p ( ’ Constru ç ã o com fun ç ã o ’ )
d i s p ( ’ =====================’ )
445 d i s p ( ’ ’ )
455 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
457 pause ( )
459 v(1)
461 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
A.S.V.
1.2. Aspectos gerais sobre o ambiente 15
463 pause ( )
465 v(2)
467 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
469 pause ( )
471 v(3)
473 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
475 pause ( )
477 %
% EOF
479 %
7
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9 % %
% Titulo : %
11 % Exemplos de a c e s s o a e s t r u t u r a s de dados %
% %
13 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
15 % Datas : /2022−01/ %
% %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
% l i m p e z a do ambiente de t r a b a l h o
21 %
clear all
23 c l o s e a l l
25
disp ( ’ ’)
27 disp ( ’ ’)
disp ( ’ ========================================’ )
29 disp ( ’ Exemplos de a c e s s o a e s t r u t u r a s de dados ’ )
disp ( ’ ========================================’ )
31 disp ( ’ ’)
33
%
35 % Exemplos de v e t o r l i n h a ( m a t r i z 1xC )
%
37
TET / UFF
16 Capı́tulo 1. Ambiente de simulação matemática
disp ( ’ ’)
39 disp ( ’ ’)
disp ( ’ ====================================’ )
41 disp ( ’ Exemplos de v e t o r l i n h a ( m a t r i z 1xC) ’ )
disp ( ’ ====================================’ )
43 disp ( ’ ’)
45 vl = 1:2:13
47 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
49 pause ( )
51 vl (3)
53 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
55 pause ( )
57 vl ([2 , 5])
59 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
61 pause ( )
63 vl (4:6)
65 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
67 pause ( )
69
%
71 % Exemplos de v e t o r c o l u n a ( m a t r i z Lx1 ) :
%
73
disp ( ’ ’ )
75 d i s p ( ’ ’ )
disp ( ’ =====================================’ )
77 d i s p ( ’ Exemplos de v e t o r c o l u n a ( m a t r i z Lx1 ) ’ )
disp ( ’ =====================================’ )
79 d i s p ( ’ ’ )
81 vc = [ 2 : 2 : 1 6 ] ’
83 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
85 pause ( )
87 vc ( 6 )
89 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
91 pause ( )
93 vc ( [ 1 , 4 ] )
95 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
A.S.V.
1.2. Aspectos gerais sobre o ambiente 17
97 pause ( )
99 vc ( 3 : 5 )
101 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
103 pause ( )
105
%
107 % Exemplos de m a t r i z r e t a n g u l a r ( m a t r i z LxC)
%
109
disp ( ’ ’ )
111 d i s p ( ’ ’ )
disp ( ’ ==========================================’ )
113 d i s p ( ’ Exemplos de m a t r i z r e t a n g u l a r ( m a t r i z LxC) ’ )
disp ( ’ ==========================================’ )
115 d i s p ( ’ ’ )
119 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
121 pause ( )
123 mlc ( 5 , 3 )
125 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
127 pause ( )
129 % ( L * ( c −1) ) + l =
% ( 6 * (3 −1) ) + 5 = 12 + 5 = 17
131 %
mlc ( 1 7 )
133
disp ( ’ ’ )
135 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
137
mlc ( 2 , 1 : 3 )
139
disp ( ’ ’ )
141 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
143
mlc ( 2 : 5 , 3 )
145
disp ( ’ ’ )
147 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
149
mlc ( 3 , : )
151
disp ( ’ ’ )
153 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
155
TET / UFF
18 Capı́tulo 1. Ambiente de simulação matemática
mlc ( : , 2 )
157
disp ( ’ ’ )
159 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
161
mlc ( [ 1 3 5 ] , [ 2 4 ] )
163
disp ( ’ ’ )
165 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
167
mlc ( 2 : 4 , 2 : 3 )
169
disp ( ’ ’ )
171 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
173
175 %
% Exemplos de m a t r i z t r i d i m e n s i o n a l ( m a t r i z LxCxP )
177 %
179 disp ( ’ ’)
disp ( ’ ’)
181 disp ( ’ ================================================’ )
disp ( ’ Exemplos de m a t r i z t r i d i m e n s i o n a l ( m a t r i z LxCxP) ’ )
183 disp ( ’ ================================================’ )
disp ( ’ ’)
185
mlcp = randn ( 6 , 4 , 3 )
187
disp ( ’ ’ )
189 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
191
mlcp ( 5 , 3 , 2 )
193
disp ( ’ ’ )
195 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
197
% ( L *C * ( p−1) ) + ( L * ( c −1) ) + l =
199 % ( 6 * 4 * (2 −1) ) + ( 6 * (3 −1) ) + 5 = 24 + 12 + 5 = 41
%
201 mlcp ( 4 1 )
203 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
205 pause ( )
207 mlcp ( 2 , 1 : 3 , 1 )
209 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
211 pause ( )
213 mlcp ( 2 : 5 , 3 , 2 )
A.S.V.
1.2. Aspectos gerais sobre o ambiente 19
215 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
217 pause ( )
219 mlcp ( [ 1 3 5 ] , [ 2 4 ] , 3 )
221 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
223 pause ( )
225 mlcp ( 2 : 4 , 2 : 3 , : )
227 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
229 pause ( )
231
%
233 % Exemplos de c e l l a r r a y
%
235
disp ( ’ ’ )
237 d i s p ( ’ ’ )
disp ( ’ ======================’ )
239 d i s p ( ’ Exemplos de c e l l a r r a y ’ )
disp ( ’ ======================’ )
241 d i s p ( ’ ’ )
243 %
% Constru ç ão com a t r i b u i ç ão
245 %
247 disp ( ’ ’)
disp ( ’ ’)
249 disp ( ’ =========================’ )
disp ( ’ Constru ç ã o com a t r i b u i ç ã o ’ )
251 disp ( ’ =========================’ )
disp ( ’ ’)
253
c = { 1 , [2 , 3] ;
255 [ 4 ; 5 ] , [ 6 , 7 ; 8 , 9 ; 10 , 1 1 ]
}
257
disp ( ’ ’ )
259 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
261
c {1 ,1}
263
disp ( ’ ’ )
265 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
267
c {1 ,2}
269
disp ( ’ ’ )
271 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
273
TET / UFF
20 Capı́tulo 1. Ambiente de simulação matemática
c {2 ,1}
275
disp ( ’ ’ )
277 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
279
c {2 ,2}
281
disp ( ’ ’ )
283 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
285
c {1 ,2}(1 ,1)
287
disp ( ’ ’ )
289 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
291
c {2 ,1}(2 ,1)
293
disp ( ’ ’ )
295 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
297
c {2 ,2}(2 ,:)
299
disp ( ’ ’ )
301 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
303
305 %
% Exemplos de s t r u c t u r e a r r a y
307 %
309 disp ( ’ ’)
disp ( ’ ’)
311 disp ( ’ ===========================’ )
disp ( ’ Exemplos de s t r u c t u r e a r r a y ’ )
313 disp ( ’ ===========================’ )
disp ( ’ ’)
315
%
317 % Constru ç ão com a t r i b u i ç ão
%
319
disp ( ’ ’ )
321 d i s p ( ’ ’ )
d i s p ( ’ =========================’ )
323 d i s p ( ’ Constru ç ã o com a t r i b u i ç ã o ’ )
d i s p ( ’ =========================’ )
325 d i s p ( ’ ’ )
327
s . nome = ’ Aluno 1 ’ ;
329 s . notas = [1.1 2.1 3 . 1 ] ;
s . s i t u a c a o = ’ Reprovado ’
331
disp ( ’ ’ )
A.S.V.
1.2. Aspectos gerais sobre o ambiente 21
333 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
335
s ( 2 ) . nome = ’ Aluno 11 ’ ;
337 s ( 2 ) . notas = [4.1 5.1 6 . 1 ] ;
s ( 2 ) . s i t u a c a o = ’VS ’
339
disp ( ’ ’ )
341 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
343
s ( 3 ) . nome = ’ Aluno 111 ’ ;
345 s ( 3 ) . notas = [7.1 8.1 9 . 1 ] ;
s ( 3 ) . s i t u a c a o = ’ Aprovado ’
347
disp ( ’ ’ )
349 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
351
s (1)
353
disp ( ’ ’ )
355 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
357
s (2)
359
disp ( ’ ’ )
361 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
363
s (3)
365
disp ( ’ ’ )
367 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
369
s ( 1 ) . nome
371
disp ( ’ ’ )
373 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
375
s ( 2 ) . notas (2)
377
disp ( ’ ’ )
379 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
381
s (3). situacao
383
disp ( ’ ’ )
385 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
387
%
389 % EOF
%
TET / UFF
22 Capı́tulo 1. Ambiente de simulação matemática
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
10 % T i t u l o : %
% Exemplos de opera ç õ e s com e s t r u t u r a s de dados %
12 % %
% %
14 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Datas : /2022−01/ %
16 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18
20 % l i m p e z a do ambien te de t r a b a l h o
%
22 c l e a r a l l
close all
24
26 disp ( ’ ’)
disp ( ’ ’)
28 disp ( ’ =============================================’ )
disp ( ’ Exemplos de o p e r a ç õ e s com e s t r u t u r a s de dados ’ )
30 disp ( ’ =============================================’ )
disp ( ’ ’)
32
34 %
% Exemplos de e s c a l a r ( m a t r i z 1 x1 )
36 %
38 e = ( −4 * (3ˆ2) ) + ( 6 * (125ˆ(1/3)) )
42
%
44 % Exemplos de v e t o r l i n h a ( m a t r i z 1xC )
%
46
vl = [ 1 2 3 ]
48
emvl = 4 * v l
50
vldde = vl / 2
52
vldee = 2 \ vl
54
vlmvl = v l . * v l
56
% Erro ! ! !
58 %
A.S.V.
1.2. Aspectos gerais sobre o ambiente 23
% vlmvl = vl * vl
60
vlddvl = vl ./ vl
62
vldevl = vl .\ vl
64
vlee = vl .ˆ 2
66
vlevl = vl .ˆ vl
68
70 %
% Exemplos de v e t o r c o l u n a ( m a t r i z Lx1 )
72 %
74 vc = [ 1 2 3 ] . ’
76 emvc = 4 * vc
78 vcdde = vc / 2
80 vcdee = 2 \ vc
82 vcmvc = vc . * vc
84 % Erro ! ! !
%
86 % vcmvc = vc * vc
88 vcddvc = vc . / vc
90 vcdevc = vc . \ vc
92 v c e e = vc . ˆ 2
94 v c e v c = vc . ˆ vc
96
%
98 % Exemplos de v e t o r l i n h a e v e t o r c o l u n a
%
100
vl = [ 1 3 5 ]
102
vc = [ 6 ; 4 ; 2 ]
104
v l p e v c = v l * vc
106
% Erro ! ! !
108 %
% vlmvc = v l . * vc
110
v l x = [ 1+ j 3+ j * 3 5+ j * 5 ]
112
v l x t c = vlx ’
114
vlxt = vlx . ’
116
vcx = [ 2+ j * 2 ; 4+ j * 4 ; 6+ j * 6 ]
TET / UFF
24 Capı́tulo 1. Ambiente de simulação matemática
118
v c x t c = vcx ’
120
vcxt = vcx . ’
122
124
%
126 % Exemplos de v e t o r l i n h a / c o l u n a e m a t r i z r e t a n g u l a r ( m a t r i z LxC)
%
128
vl = [ 1 3 ]
130
vc = [ 6 ; 4 ; 2 ]
132
mr = [ 10 20 30 ; 40 50 60 ]
134
vlmmr = v l * mr
136
mrmvc = mr * vc
138
140 %
% Exemplos de m a t r i z r e t a n g u l a r ( m a t r i z LxC)
142 %
144 mr = [ 1 2 3 ; 4 5 6 ]
146 mrmmr = mr . * mr
148 mree = mr . ˆ 3
150 mrmmrt = mr * mr . ’
152 mrtmmr = mr . ’ * mr
A.S.V.
1.3. Representação gráfica bidimensional (curvas) 25
• Porém, a partir de pontos do gráfico contı́nuo, pode-se obter uma aproximação interpo-
lada.
1.3.4 Códigos
• O Código 1.4 apresenta um exemplo de gráfico discreto de função unidimensional.
• O Código 1.8 apresenta um exemplo de criação de curva discreta, de curva contı́nua por
meio de interpolador de ordem 0 e de curva contı́nua por meio de interpolador de ordem 1.
TET / UFF
26 Capı́tulo 1. Ambiente de simulação matemática
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
3 % Arquivo : A u l a 3 L a b O c t a v e C u r v a s 1 .m
%
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9 % %
% Titulo : %
11 % Exemplo de g r á f i c o d i s c r e t o de fun ç ão u n i d i m e n s i o n a l %
% %
13 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
15 % Datas : /2022−01/ %
% %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
% l i m p e z a do ambien te de t r a b a l h o
21 clear all
close all
23
% d e f i n i c a o da a b s c i s s a
25 n = −5:5;
27 % d e f i n i c a o da ordenada
a2 = 1 ;
29 a1 = 0 ;
a0 = 0 ;
31 y = a2 . * ( n . ˆ 2 ) + a1 . * n + a0 ;
39 % c r i a c a o de l a b e l s
xlabel ( ’n ’ )
41 y l a b e l ( ’ y [ n ] = a 2 nˆ2 + a 1 n + a 0 ’ )
43 % c r i a c a o de t i t u l o
t i t l e ( ’ Grá f i c o d i s c r e t o de fun ç ã o u n i d i m e n s i o n a l ’ )
45
% c o n t r o l e de f a i x a s
47 f a i x a = [ −10 10 −5 3 0 ] ;
axis ( faixa )
49
%
51 %EOF
%
A.S.V.
1.3. Representação gráfica bidimensional (curvas) 27
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
10 % T i t u l o : %
% Exemplo de c r i a ç ão de s u b j a n e l a s em uma mesma t e l a %
12 % %
% %
14 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Datas : /2022−01/ %
16 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18
20 % l i m p e z a do ambiente de t r a b a l h o
clear all
22 c l o s e a l l
24 % d e f i n i c a o da a b s c i s s a
n = −1.5:0.01:1.5;
26
% d e f i n i c a o da ordenada
28 y1 = ( n ) ;
y2 = ( n . ˆ 2 ) ;
30 y3 = ( n . ˆ 3 ) ;
y4 = ( n . ˆ 4 ) ;
32
% c r i a c a o de uma t e l a de desenho ( canvas )
34 f i g u r e ( 2 )
36 % c r i a c a o de s u b j a n e l a na t e l a
subplot (2 ,2 ,1)
38
% c r i a c a o de desenho
40 stem ( n , y1 , ’ b ’ )
42 % c r i a c a o de t i t u l o
t i t l e ( ’ P o l i n ô mios de grau ı́ mpar ’ )
44
% c r i a c a o de l a b e l s
46 y l a b e l ( ’ y [ n ] = nˆ1 ’ )
48 % c r i a c a o de s u b j a n e l a na t e l a
subplot (2 ,2 ,2)
50
% c r i a c a o de desenho
52 stem ( n , y2 , ’ g ’ )
54 % c r i a c a o de t i t u l o
t i t l e ( ’ P o l i n ô mios de grau ı́ mpar ’ )
56
% c r i a c a o de l a b e l s
58 y l a b e l ( ’ y [ n ] = nˆ2 ’ )
TET / UFF
28 Capı́tulo 1. Ambiente de simulação matemática
60 % c r i a c a o de s u b j a n e l a na t e l a
subplot (2 ,2 ,3)
62
% c r i a c a o de desenho
64 stem ( n , y3 , ’ r ’ )
66 % c r i a c a o de l a b e l s
y l a b e l ( ’ y [ n ] = nˆ3 ’ )
68 x l a b e l ( ’ n ’ )
70 % c r i a c a o de s u b j a n e l a na t e l a
subplot (2 ,2 ,4)
72
% c r i a c a o de desenho
74 stem ( n , y4 , ’ k ’ )
76 % c r i a c a o de l a b e l s
y l a b e l ( ’ y [ n ] = nˆ4 ’ )
78 x l a b e l ( ’ n ’ )
80
%
82 %EOF
%
7
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9 % %
% Titulo : %
11 % Exemplo de s u p e r p o s i ç ão de g r á f i c o s d i s c r e t o s %
% %
13 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
15 % Datas : /2022−01/ %
% %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
% l i m p e z a do ambien te de t r a b a l h o
21 clear all
close all
23
% d e f i n i c a o da a b s c i s s a
25 n = −1.5:0.01:1.5;
27 % d e f i n i c a o da ordenada
y1 = ( n ) ;
29 y2 = ( n . ˆ 2 ) ;
A.S.V.
1.3. Representação gráfica bidimensional (curvas) 29
y3 = ( n . ˆ 3 ) ;
31 y4 = ( n . ˆ 4 ) ;
39 % c r i a c a o de desenho
stem ( n , y1 , ’ b ’ )
41 stem ( n , y2 , ’ g ’ )
stem ( n , y3 , ’ r ’ )
43 stem ( n , y4 , ’ k ’ )
45 % c r i a c a o de l e g e n d a
l e g e n d ( ’ nˆ1 ’ , ’ nˆ2 ’ , ’ nˆ3 ’ , ’ nˆ4 ’ , ’ L o c a t i o n ’ , ’ s o u t h e a s t ’ )
47
% c r i a c a o de l a b e l s
49 x l a b e l ( ’ n ’ )
y l a b e l ( ’ y [ n ] = nˆk , k = 1:4 ’ )
51
% c r i a c a o de t i t u l o
53 t i t l e ( ’ S u p e r p o s i ç ã o de g r á f i c o s d i s c r e t o s ’ )
55 %
%EOF
57 %
7
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9 % %
% Titulo : %
11 % Exemplo de c r i a ç ão de s u b j a n e l a ocupando v á r i o s e s p a ç os %
% %
13 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
15 % Datas : /2022−01/ %
% %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
% l i m p e z a do ambiente de t r a b a l h o
21 clear all
close all
23
% d e f i n i c a o da a b s c i s s a
25 n = −1.5:0.01:1.5;
TET / UFF
30 Capı́tulo 1. Ambiente de simulação matemática
27
% d e f i n i c a o da ordenada
29 y1 = ( n ) ;
y2 = ( n . ˆ 2 ) ;
31 y3 = ( n . ˆ 3 ) ;
y4 = ( n . ˆ 4 ) ;
33
% c r i a c a o de uma t e l a de desenho ( canvas )
35 f i g u r e ( 4 )
37 % c r i a c a o de s u b j a n e l a na t e l a
subplot (2 ,4 ,1)
39
% c r i a c a o de desenho
41 stem ( n , y1 , ’ b ’ )
43 % c r i a c a o de t i t u l o
t i t l e ( ’ P o l i n ô mios de grau ı́ mpar ’ )
45
% c r i a c a o de l a b e l s
47 y l a b e l ( ’ y [ n ] = nˆ1 ’ )
49 % c r i a c a o de s u b j a n e l a na t e l a
subplot (2 ,4 ,4)
51
% c r i a c a o de desenho
53 stem ( n , y2 , ’ g ’ )
55 % c r i a c a o de t i t u l o
t i t l e ( ’ P o l i n ô mios de grau par ’ )
57
% c r i a c a o de l a b e l s
59 y l a b e l ( ’ y [ n ] = nˆ2 ’ )
61 % c r i a c a o de s u b j a n e l a na t e l a
subplot (2 ,4 ,5)
63
% c r i a c a o de desenho
65 stem ( n , y3 , ’ r ’ )
67 % c r i a c a o de l a b e l s
y l a b e l ( ’ y [ n ] = nˆ3 ’ )
69 x l a b e l ( ’ n ’ )
71 % c r i a c a o de s u b j a n e l a na t e l a
subplot (2 ,4 ,8)
73
% c r i a c a o de desenho
75 stem ( n , y4 , ’ k ’ )
77 % c r i a c a o de l a b e l s
y l a b e l ( ’ y [ n ] = nˆ4 ’ )
79 x l a b e l ( ’ n ’ )
81 % c r i a c a o de s u b j a n e l a na t e l a
subplot ( 2 , 4 , [ 2 : 3 6 : 7 ] )
83
% h a b i l i t a c a o da s u p e r p o s i c a o
85 h o l d on
A.S.V.
1.3. Representação gráfica bidimensional (curvas) 31
87 % c r i a c a o de desenho na t e l a
stem ( n , y1 , ’ b ’ )
89 stem ( n , y2 , ’ g ’ )
stem ( n , y3 , ’ r ’ )
91 stem ( n , y4 , ’ k ’ )
93 % c r i a c a o de l e g e n d a
l e g e n d ( ’ nˆ1 ’ , ’ nˆ2 ’ , ’ nˆ3 ’ , ’ nˆ4 ’ , ’ L o c a t i o n ’ , ’ s o u t h e a s t ’ )
95
% c r i a c a o de l a b e l s
97 x l a b e l ( ’ n ’ )
y l a b e l ( ’ y [ n ] = nˆk , k = 1:4 ’ )
99
% c r i a c a o de t i t u l o
101 t i t l e ( ’ S u p e r p o s i ç ã o de g r á f i c o s d i s c r e t o s ’ )
103
%
105 %EOF
%
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
10 % T i t u l o : %
% Exemplo de c r i a ç ão : %
12 % de c u r v a d i s c r e t a , %
% de c u r v a c o n t ı́ nua por meio de i n t e r p o l a d o r de ordem 0 %
14 % e %
% de c u r v a c o n t ı́ nua por meio de i n t e r p o l a d o r de ordem 1 %
16 % %
% %
18 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Datas : /2022−01/ %
20 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22
24 % l i m p e z a do ambiente de t r a b a l h o
clear all
26 c l o s e a l l
28 % d e f i n i c a o do p e r i o d o
Np = 4 0 ;
30
% d e f i n i c a o do i n d i c e
32 n = 0 : Np ;
TET / UFF
32 Capı́tulo 1. Ambiente de simulação matemática
34 % d e f i n i c a o da f r e q u e n c i a d i s c r e t a
Omega = 2 * p i / Np ;
36
% d e f i n i c a o da a m p l i t u d e
38 A = 1 ;
40 % d e f i n i c a o da a b s c i s s a
y = A * c o s (Omega * n ) ;
42
% d e f i n i c a o do p e r i o d o de amostragem e do tempo
44 Ts = 1 / 44 e3 ;
t = n * Ts ;
46
%
48 FigNbr = 4 ;
50 %
FigNbr = FigNbr + 1 ;
52 f i g u r e ( FigNbr )
%
54 s u b p l o t ( 2 , 2 , 1 )
stem ( n , y , ’ k ’ )
56 t i t l e ( ’ Curva d i s c r e t a ’ )
y l a b e l ( ’ y [ n ] = A c o s ( \Omega n + \ Theta ) ’ )
58 x l a b e l ( ’ n ’ )
a x i s ( [ 0 n ( end ) min ( y ) max( y ) ] )
60 %
subplot (2 ,2 ,2)
62 s t a i r s ( t , y , ’ r ’ )
t i t l e ( { ’ Curva p r o d u z i d a por i n t e r p o l a d o r de ordem 0 (ZOH) ’ ,
64 ’ com Fs = 44 kHz ’ } )
y l a b e l ( ’ y ( t ) = ZOH \{ y [ n ] \} ’ )
66 x l a b e l ( ’ t ( s ) ’ )
a x i s ( [ 0 t ( end ) min ( y ) max( y ) ] )
68 %
subplot (2 ,2 ,3)
70 p l o t ( t , y , ’ b ’ )
t i t l e ( { ’ Curva p r o d u z i d a por i n t e r p o l a d o r de ordem 1 (FOH) ’ ,
72 ’ com Fs = 44 kHz ’ } )
y l a b e l ( ’ y ( t ) = FOH \{ y [ n ] \} ’ )
74 x l a b e l ( ’ t ( s ) ’ )
a x i s ( [ 0 t ( end ) min ( y ) max( y ) ] )
76 %
subplot (2 ,2 ,4)
78 h o l d on
stem ( t , y , ’ k ’ )
80 s t a i r s ( t , y , ’ r ’ )
plot ( t , y , ’b ’ )
82 t i t l e ( ’ S u p e r p o s i ç ã o das c u r v a s ’ )
%y l a b e l ( ’ y [ n ] = s i n (\Omega n ) ’ )
84 x l a b e l ( ’ t ( s ) ’ )
a x i s ( [ 0 t ( end ) min ( y ) max( y ) ] )
86
88 %
%EOF
90 %
A.S.V.
1.4. Representação gráfica tridimensional (curvas e superfı́cies) 33
• Porém, a partir de pontos do gráfico contı́nuo, pode-se obter uma aproximação interpo-
lada.
1.4.4 Códigos
• O Código 1.9 apresenta um exemplo de criação de curva 3D. Relações entre exp(), sin()
e cos(). Casos discreto e contı́nuo.
TET / UFF
34 Capı́tulo 1. Ambiente de simulação matemática
10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 % %
% Titulo : %
14 % Exemplo de c r i a c a o de c u r v a 3D %
% − R e l a c o e s : exp ( ) , s i n ( ) e c o s ( ) . %
16 % − Casos : c o n t i n u o e d i s c r e t o . %
% %
18 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
20 % Datas : /2021 0 7 0 5 / %
% %
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24
% l i m p e z a do ambien te de t r a b a l h o
26 clear all
close all
28
% d e f i n i c a o do p e r i o d o
30 Np = 4 0 ;
32 % d e f i n i c a o do i n d i c e
n = 0 : Np ;
34
% d e f i n i c a o da f r e q u e n c i a d i s c r e t a
36 Omega = 2 * p i / Np ;
38 % d e f i n i c a o da a b s c i s s a
x = c o s (Omega * n ) ;
40
% d e f i n i c a o da ordenada
42 y = s i n (Omega * n ) ;
44 % d e f i n i c a o da a l t u r a
z = n;
46
% d e f i n i c a o do p e r i o d o de amostragem e do tempo
48 Ts = 1 / 44 e3 ;
t = n * Ts ;
50
52 %
FigNbr = 0 ;
54 b l a c k v a l = 0 ;
56 %
FigNbr = FigNbr + 1 ;
58 f i g u r e ( FigNbr )
%
60 %
subplot (2 ,2 ,1)
62 p l o t ( x , y , ”o ”)
axis square
64 t i t l e ( ’ Curva d i s c r e t a 2D: e ˆ{ j ( \Omega n ) } ’ )
y l a b e l ( ’ y [ n ] = s i n ( \Omega n ) ’ )
66 x l a b e l ( ’ x [ n ] = c o s ( \Omega n ) ’ )
%
A.S.V.
1.4. Representação gráfica tridimensional (curvas e superfı́cies) 35
68 % fundo p r e t o
%s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
70 %
subplot (2 ,2 ,2)
72 stem ( n , y )
a x i s ( [ 0 n ( end ) min ( y ) max( y ) ] )
74 t i t l e ( ’ P r o j e c a o no e i x o Y ’ )
y l a b e l ( ’ y [ n ] = s i n ( \Omega n ) ’ )
76 x l a b e l ( ’ n ’ )
% fundo p r e t o
78 %s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
%
80 s u b p l o t ( 2 , 2 , 3 )
stem ( n , x )
82 a x i s s q u a r e
a x i s ( [ 0 n ( end ) min ( y ) max( y ) ] )
84 t i t l e ( ’ P r o j e c a o no e i x o X ’ )
y l a b e l ( ’ x [ n ] = c o s ( \Omega n ) ’ )
86 x l a b e l ( ’ n ’ )
%
88 % fundo p r e t o
%s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
90 %
%v i e w (AZIMUTH, ELEVATION)
92 view ( 9 0 , 9 0 )
94 %
disp ( ’ ’ )
96 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
98
%
100 FigNbr = FigNbr + 1 ;
f i g u r e ( FigNbr )
102 %
subplot (2 ,2 ,1)
104 p l o t ( x , y )
axis square
106 t i t l e ( ’ Curva c o n t i n u a 2D: e ˆ{ j ( \ omega t ) } ’ )
y l a b e l ( ’ y ( t ) = s i n ( \ omega t ) ’ )
108 x l a b e l ( ’ x ( t ) = c o s ( \ omega t ) ’ )
%
110 % fundo p r e t o
%s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
112 %
subplot (2 ,2 ,2)
114 p l o t ( t , y )
a x i s ( [ 0 t ( end ) min ( y ) max( y ) ] )
116 t i t l e ( ’ P r o j e c a o no e i x o Y ’ )
y l a b e l ( ’ y ( t ) = s i n ( \ omega t ) ’ )
118 x l a b e l ( ’ t ’ )
%
120 % fundo p r e t o
%s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
122 %
subplot (2 ,2 ,3)
124 p l o t ( t , x )
axis square
126 a x i s ( [ 0 t ( end ) min ( y ) max( y ) ] )
TET / UFF
36 Capı́tulo 1. Ambiente de simulação matemática
t i t l e ( ’ P r o j e c a o no e i x o X ’ )
128 y l a b e l ( ’ x ( t ) = c o s ( \ omega t ) ’ )
xlabel ( ’ t ’ )
130 %
% fundo p r e t o
132 %s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
%
134 %v i e w (AZIMUTH, ELEVATION)
view ( 9 0 , 9 0 )
136
%
138 d i s p ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
140 pause ( )
142 %
FigNbr = FigNbr + 1 ;
144 f i g u r e ( FigNbr )
%
146 s u b p l o t ( 2 , 2 , 1 )
p l o t ( x , y , ”o ”)
148 a x i s s q u a r e
t i t l e ( ’ P r o j e c a o no p l a n o X x Y ’ )
150 y l a b e l ( ’ y [ n ] = s i n ( \Omega n ) ’ )
x l a b e l ( ’ x [ n ] = c o s ( \Omega n ) ’ )
152 %
% fundo p r e t o
154 %s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
%
156 s u b p l o t ( 2 , 2 , 2 )
stem ( n , y )
158 a x i s ( [ 0 n ( end ) min ( y ) max( y ) ] )
t i t l e ( ’ P r o j e c a o no p l a n o Z x Y ’ )
160 y l a b e l ( ’ y [ n ] = s i n ( \Omega n ) ’ )
xlabel ( ’z [n] = n ’ )
162 %
% fundo p r e t o
164 %s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
%
166 s u b p l o t ( 2 , 2 , 3 )
stem ( n , x )
168 a x i s s q u a r e
a x i s ( [ 0 n ( end ) min ( y ) max( y ) ] )
170 t i t l e ( ’ P r o j e c a o no p l a n o Z x X ’ )
y l a b e l ( ’ x [ n ] = c o s ( \Omega n ) ’ )
172 x l a b e l ( ’ z [ n ] = n ’ )
%
174 % fundo p r e t o
%s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
176 %
%v i e w (AZIMUTH, ELEVATION)
178 view ( 9 0 , 9 0 )
%
180 s u b p l o t ( 2 , 2 , 4 )
stem3 ( x , y , z )
182 t i t l e ( ’ Curva d i s c r e t a 3D: e ˆ{ j ( \Omega n ) } ’ )
zlabel ( ’z [n] = n ’ )
184 y l a b e l ( ’ y [ n ] = s i n ( \Omega n ) ’ )
x l a b e l ( ’ x [ n ] = c o s ( \Omega n ) ’ )
A.S.V.
1.4. Representação gráfica tridimensional (curvas e superfı́cies) 37
186 %
% fundo p r e t o
188 %s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
190 %
disp ( ’ ’ )
192 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
194
%
196 FigNbr = FigNbr + 1 ;
f i g u r e ( FigNbr )
198 %
subplot (2 ,2 ,1)
200 p l o t ( x , y )
axis square
202 t i t l e ( ’ P r o j e c a o no p l a n o X x Y ’ )
y l a b e l ( ’ y ( t ) = s i n ( \ omega t ) ’ )
204 x l a b e l ( ’ x ( t ) = c o s ( \ omega t ) ’ )
%
206 % fundo p r e t o
%s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
208 %
subplot (2 ,2 ,2)
210 p l o t ( t , y )
a x i s ( [ 0 t ( end ) min ( y ) max( y ) ] )
212 t i t l e ( ’ P r o j e c a o no p l a n o Z x Y ’ )
y l a b e l ( ’ y ( t ) = s i n ( \ omega t ) ’ )
214 x l a b e l ( ’ z ( t ) = t ’ )
%
216 % fundo p r e t o
%s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
218 %
subplot (2 ,2 ,3)
220 p l o t ( t , x )
axis square
222 a x i s ( [ 0 t ( end ) min ( y ) max( y ) ] )
t i t l e ( ’ P r o j e c a o no p l a n o Z x X ’ )
224 y l a b e l ( ’ x ( t ) = c o s ( \ omega t ) ’ )
xlabel ( ’z( t ) = t ’ )
226 %
% fundo p r e t o
228 %s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
%
230 %v i e w (AZIMUTH, ELEVATION)
view ( 9 0 , 9 0 )
232 %
subplot (2 ,2 ,4)
234 p l o t 3 ( x , y , t )
g r i d on
236 t i t l e ( ’ Curva c o n t i n u a 3D: e ˆ{ j ( \ omega t ) } ’ )
zlabel ( ’z( t ) = t ’ )
238 y l a b e l ( ’ y ( t ) = s i n ( \ omega t ) ’ )
x l a b e l ( ’ x ( t ) = c o s ( \ omega t ) ’ )
240 %
% fundo p r e t o
242 %s e t ( gca , ’ c o l o r ’ , [ b l a c k v a l , b l a c k v a l , b l a c k v a l ] )
244 %
TET / UFF
38 Capı́tulo 1. Ambiente de simulação matemática
%EOF
246 %
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
10 % T i t u l o : %
% Exemplo de c r i a c a o de s u p e r f i c i e d i s c r e t a 3D %
12 % %
% %
14 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Datas : /2022−01/ %
16 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18
20 % l i m p e z a do ambien te de t r a b a l h o
clear all
22 c l o s e a l l
24 %
x = −1:0.01:1;
26 y = x ;
[ X,Y] = meshgrid ( x , y ) ;
28
%
30 %z = s q r t (X) + s q r t (Y) ;
z = X. ˆ 2 + Y. ˆ 2 ;
32
%
34 FigNbr = 0 ;
36 %
FigNbr = FigNbr + 1 ;
38 f i g u r e ( FigNbr )
%
40 s u r f (X, Y, z )
42 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
44 pause ( )
46 %
FigNbr = FigNbr + 1 ;
48 f i g u r e ( FigNbr )
%
50 s u r f c (X, Y, z )
52 disp ( ’ ’ )
A.S.V.
1.4. Representação gráfica tridimensional (curvas e superfı́cies) 39
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
54 pause ( )
56 %
FigNbr = FigNbr + 1 ;
58 f i g u r e ( FigNbr )
%
60 mesh (X, Y, z )
62 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
64 pause ( )
66 %
FigNbr = FigNbr + 1 ;
68 f i g u r e ( FigNbr )
%
70 meshc (X, Y, z )
72 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
74 pause ( )
76 %
FigNbr = FigNbr + 1 ;
78 f i g u r e ( FigNbr )
%
80 meshz (X, Y, z )
82 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
84 pause ( )
86 %
FigNbr = FigNbr + 1 ;
88 f i g u r e ( FigNbr )
%
90 w a t e r f a l l (X, Y, z )
92 %
% EOF
94 %
TET / UFF
40 Capı́tulo 1. Ambiente de simulação matemática
A.S.V.
1.5. Representação gráfica tridimensional (imagens) 41
– Contém valores inteiros, que servem de ı́ndices para acesso ao mapa de cores.
– Para dados uint8/16, a faixa de ı́ndices é [0;Lm-1].
– Para dados double, a faixa de ı́ndices é [1;Lm].
– O aplicativo não realiza operações matemáticas sobre dados uint8 e uint16. Para
isso, podem-se empregar as seguintes conversões:
∗ uint8 −→ double: M64 = double(M8) + 1.
∗ uint16 −→ double: M64 = double(M16) + 1.
∗ double −→ uint8 : M8 = uint8 ( round(M64 - 1) ).
∗ double −→ uint16: M16 = uint16( round(M64 - 1) ).
• Matriz de pixels (LxC): contém valores de intensidade, que se encontram dentro de alguma
faixa.
TET / UFF
42 Capı́tulo 1. Ambiente de simulação matemática
• Matriz de pixels (LxCx3): contém valores de intensidade, para cada uma das cores básicas
(RGB).
A.S.V.
1.5. Representação gráfica tridimensional (imagens) 43
– 1 cor: white.
– 16 cores: vga.
– 64 cores: hsv, hot, gray, bone, copper, pink, flag, lines, colorcube, jet, prism, cool,
autumn, spring, winter, summer.
1.5.6 Códigos
• O Código 1.11 apresenta exemplos básicos na geração de imagens em tons de cinza.
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
10 % T i t u l o : %
% Exemplo de g r á f i c o d i s c r e t o de fun ç ão b i d i m e n s i o n a l %
12 % − Imagem %
% %
14 % Exemplos b á s i c o s na g e r a ç ão de imagens em t o n s de c i n z a %
% %
16 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
18 % Datas : /2022−01/ %
% %
20 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22
%
24 % ====================================================
%
26
% l i m p e z a do ambiente de t r a b a l h o
28 %
clear all
30 c l o s e a l l
32 %
% ====================================================
34 %
TET / UFF
44 Capı́tulo 1. Ambiente de simulação matemática
36 % d e f i n e n i v e i s de branco e p r e t o
c black = 0;
38 c w h i t e = 6 4 ;
40 % i n i c i a l i z a o numero do canvas
FigNbr = 0 ;
42
%
44 % ====================================================
%
46
% desenha 1 p i x e l
48 %
FigNbr = FigNbr+1 ;
50 f i g u r e ( FigNbr )
%
52 map = gray ;
colormap (map ) ;
54 %
m image = [ c b l a c k ] ;
56 %
image ( m image )
58 f = s i z e ( m image ) ;
a x i s ( [ 0 f (2)+1 0 f ( 1 ) + 1 ] )
60
disp ( ’ ’ )
62 d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
pause ( )
64
axis square
66 %a x i s image
68 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
70 pause ( )
72 %
% ====================================================
74 %
A.S.V.
1.5. Representação gráfica tridimensional (imagens) 45
94
axis square
96 %a x i s image
98 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
100 pause ( )
102 %
% ====================================================
104 %
128 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
130 pause ( )
132 %
% ====================================================
134 %
TET / UFF
46 Capı́tulo 1. Ambiente de simulação matemática
pause ( )
154
axis square
156 %a x i s image
158 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
160 pause ( )
162 %
% ====================================================
164 %
190 disp ( ’ ’ )
d i s p ( ’ P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ’ )
192 pause ( )
A.S.V.
1.6. Simulação de uma equação de diferença 47
• Considerando-se x[n] = 0, para n < 0, e as condições iniciais yCI = {y[−1], ..., y[−N ]},
pode-se calcular o valor de y[n], para n ≥ 0, por meio de um processo iterativo, tal como:
a1 aN b0 b1 bL
y[n] = − y[n − 1] − . . . − y[n − N ] + x[n] + x[n − 1] + . . . + x[n − L] . (1.2)
a0 a0 a0 a0 a0
y = f ilter(b, a, x) ,
1.6.3 Códigos
• O Código 1.12 apresenta um exemplo de simulação de uma equação de diferença.
7
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9 % %
TET / UFF
48 Capı́tulo 1. Ambiente de simulação matemática
% Titulo : %
11 % Exemplo de s i m u l a ç ão de uma equa ç ão de d i f e r e n ç a %
% %
13 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
15 % Datas : /2022−01/ %
% %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
%
21 % ====================================================
%
23
% l i m p e z a do ambien te de t r a b a l h o
25 %
clear all
27 c l o s e a l l
29 %
% ====================================================
31 %
33 % d e f i n e os c o e f i c i e n t e s da equacao de d i f e r e n c a
%
35 % b = [ b0 b1 b2 ]
b = [ 0.435390588649551 0.507111243808470 0.435390588649552 ] ;
37 %
% a = [ a0 a1 a2 ]
39 a = [ 1.000000000000000 0.113933557377612 0.263958863729961 ] ;
41 % i n i c i a l i z a o numero do canvas
FigNbr = 0 ;
43
%
45 % ====================================================
%
47
% d e f i n e um i m p u l s o d i s c r e t o u n i t a r i o
49 %
Nud = 2 1 ;
51 %
u n i t d e l t a = z e r o s ( 1 , Nud ) ;
53 u n i t d e l t a ( 1 ) = 1 ;
55 % d e f i n e um d e gr a u d i s c r e t o u n i t a r i o
%
57 Nus = 3 1 ;
%
59 u n i t s t e p = ones ( 1 , Nus ) ;
61 % d e f i n e um g a t e r e t a n g u l a r u n i t a r i o d e s l o c a d o
%
63 Nurg = 6 1 ;
u n i t r e t g a t e = z e r o s ( 1 , Nurg ) ;
65 u n i t r e t g a t e ( 1 0 : 2 0 ) = 1 ;
u n i t r e t g a t e ( 4 0 : 5 0 ) = −1;
67
%
A.S.V.
1.6. Simulação de uma equação de diferença 49
69 % ====================================================
%
71
% c a l c u l a s a i d a para
73 % um i m p u l s o d i s c r e t o u n i t a r i o
%
75 y ud = f i l t e r ( b , a , u n i t d e l t a ) ;
77 % c a l c u l a s a i d a para
% um d eg r a u d i s c r e t o u n i t a r i o
79 %
y us = f i l t e r (b , a , u n i t s t e p ) ;
81
% c a l c u l a s a i d a para
83 % um g a t e r e t a n g u l a r u n i t a r i o d e s l o c a d o
%
85 y urg = f i l t e r (b , a , u n i t r e t g a t e ) ;
87 %
% ====================================================
89 %
91 % desenha g r a f i c o s das r e s p o s t a s
%
93 FigNbr = FigNbr+1 ;
f i g u r e ( FigNbr )
95 %
%
97 s u b p l o t ( 3 , 2 , 1 )
stem ( ( 0 : ( Nud−1)) , u n i t d e l t a )
99 y l a b e l ( ’ y {ud} [ n ] ’ )
t i t l e ( ’ Impulso d i s c r e t o u n i t á r i o ’ )
101 v = a x i s ;
v(1) = 0; % x min
103 v ( 2 ) = ( Nurg −1); % x max
v ( 3 ) = −1.5; % y min
105 v ( 4 ) = 1 . 5 ; % y max
axis ( [ v(1) v(2) v(3) v(4) ] )
107 %
subplot (3 ,2 ,3)
109 stem ( ( 0 : ( Nus −1)) , u n i t s t e p )
y l a b e l ( ’ y { us } [ n ] ’ )
111 t i t l e ( ’ Degrau d i s c r e t o u n i t á r i o ’ )
v = axis ;
113 v ( 1 ) = 0 ; % x min
v ( 2 ) = ( Nurg −1); % x max
115 v ( 3 ) = −1.5; % y min
v(4) = 1 .5; % y max
117 a x i s ( [ v ( 1 ) v ( 2 ) v ( 3 ) v ( 4 ) ] )
%
119 s u b p l o t ( 3 , 2 , 5 )
stem ( ( 0 : ( Nurg −1)) , u n i t r e t g a t e )
121 y l a b e l ( ’ y { urg } [ n ] ’ )
t i t l e ( ’ Gate r e t a n g u l a r u n i t á r i o d e s l o c a d o ’ )
123 v = a x i s ;
v(1) = 0; % x min
125 v ( 2 ) = ( Nurg −1); % x max
v ( 3 ) = −1.5; % y min
127 v ( 4 ) = 1 . 5 ; % y max
TET / UFF
50 Capı́tulo 1. Ambiente de simulação matemática
A.S.V.
1.7. Exercı́cios propostos 51
2. Crie um vetor coluna contendo os valores ı́mpares contidos na faixa n = [2; 22].
3. Crie um vetor linha contendo os valores pares contidos na faixa n = [21; 53], seguidos dos
valores ı́mpares contidos na faixa n = [72; 92].
4. Crie um vetor linha contendo os valores v = {33, 42, 97, 53, 64, 75}.
5. Crie um vetor linha contendo os valores v = {75, 64, 53, 97, 42, 33}, a partir de um dado
vetor linha contendo os valores v = {33, 42, 97, 53, 64, 75}.
6. Crie um vetor coluna contendo os valores v = {75, 64, 53, 97, 42, 33}.
7. Crie um vetor coluna contendo os valores v = {33, 42, 97, 53, 64, 75}, a partir de um dado
vetor coluna contendo os valores v = {75, 64, 53, 97, 42, 33}.
8. Crie um vetor coluna contendo os valores v = {75, 64, 53, 97, 42, 33}, a partir de um dado
vetor linha contendo os valores v = {33, 42, 97, 53, 64, 75}.
9. Crie um vetor linha contendo os valores v = {75, 64, 53, 97, 42, 33}, a partir de um dado
vetor coluna contendo os valores v = {33, 42, 97, 53, 64, 75}.
10. Crie um vetor linha contendo os valores v = {43, 21, 10, 65, 54, 32}, a partir de um dado
vetor linha contendo os valores v = {10, 21, 32, 43, 54, 65}.
11. Crie um vetor linha contendo os valores v = {10, 21, 0, 0, 54, 65}, a partir de um dado
vetor linha contendo os valores v = {10, 21, 32, 43, 54, 65}.
12. Crie um vetor linha contendo os valores v = {10, 0, 32, 0, 0, 65}, a partir de um dado vetor
linha contendo os valores v = {10, 21, 32, 43, 54, 65}.
13. Crie um vetor linha contendo os valores v = {10, 21, 54, 65}, a partir de um dado vetor
linha contendo os valores v = {10, 21, 32, 43, 54, 65}.
14. Crie um vetor linha contendo os valores v = {10, 32, 65}, a partir de um dado vetor linha
contendo os valores v = {10, 21, 32, 43, 54, 65}.
TET / UFF
52 Capı́tulo 1. Ambiente de simulação matemática
62 14 108 −31 88
16 25
v1 = [1, 7, 31, 22, 93], v2 = [88, −31, 108, 14, 62], v3 = [72, −11], m4 = e
48 53
0.3 6
m5 = .
1 19
1 7 31 22 93 44
48 16 72 0.3 1 58
7. Crie a matriz M = 53 25 −11 6 19 39 a partir das seguintes submatrizes:
62 14 108 −31 88 17
v1 = [1,
48, 53, 62],
v2 = [88,
93, 1, 19], v3 = [17, 39],
v4 = [93, 44, 22], v5 = [48, 16, 72, 0.3, 1, 58],
7 16 14 108 −31 88
m6 = e m7 = .
31 72 25 −11 6 19
1 6 11 16
1 2 3 4 5
2 7 12 17
6 7 8 9 10
8. Crie a matriz M2 =
3 8 13 18 a partir da matriz M1 =
11 12 13 14 15
.
4 9 14 19
16 17 18 19 20
5 10 15 20
A.S.V.
1.7. Exercı́cios propostos 53
5 4 3 2 1 1 2 3 4 5
10 9 8 7 6 6 7 8 9 10
9. Crie a matriz M2 =
15 14 13
a partir da matriz M1 = .
12 11 11 12 13 14 15
20 19 18 17 16 16 17 18 19 20
16 17 18 19 20 1 2 3 4 5
11 12 13 14 15 6 7 8 9 10
10. Crie a matriz M2 =
6 7 8
a partir da matriz M1 = .
9 10 11 12 13 14 15
1 2 3 4 5 16 17 18 19 20
6 7 8 9 10 1 2 3 4 5
11 12 13 14 15 6 7 8 9 10
11. Crie a matriz M2 =
16 17 18
a partir da matriz M1 = .
19 20 11 12 13 14 15
1 2 3 4 5 16 17 18 19 20
16 17 18 19 20 1 2 3 4 5
1 2 3 4 5 6 7 8 9 10
12. Crie a matriz M2 =
6 7 8
a partir da matriz M1 = .
9 10 11 12 13 14 15
11 12 13 14 15 16 17 18 19 20
4 5 1 2 3 1 2 3 4 5
9 10 6 7 8 6 7 8 9 10
13. Crie a matriz M2 =
14 15 11
a partir da matriz M1 = .
12 13 11 12 13 14 15
19 20 16 17 18 16 17 18 19 20
3 4 5 1 2 1 2 3 4 5
8 9 10 6 7 6 7 8 9 10
14. Crie a matriz M2 =
13 14 15
a partir da matriz M1 = .
11 12 11 12 13 14 15
18 19 20 16 17 16 17 18 19 20
(a) A ∗ B, B ∗ A, A. ∗ B, B. ∗ A.
(b) A/B, A\B, B/A, B\A,
A ∗ inv(B), inv(A) ∗ B, B ∗ inv(A), inv(B) ∗ A,
(B 0 \A0 )0 , (A0 \B 0 )0 ,
inv(B 0 ) ∗ A0 , inv(A0 ) ∗ B 0 ,
A./B, A.\B, B./A, B.\A.
2. Mostre como usar a função f ind(·) para encontrar elementos genéricos em uma matriz.
3. Mostre como usar a função sign(·) para encontrar elementos genéricos em uma matriz.
TET / UFF
54 Capı́tulo 1. Ambiente de simulação matemática
A.S.V.
Capı́tulo 2
Conceitos básicos
2.1 Introdução
Na primeira parte do curso, são abordados conceitos básicos relativos ao processamento di-
gital de sinais. Inicialmente, é discutida a arquitetura de sistemas de comunicação. Em seguida,
o processamento de sinais é definido, identificando-se seu objeto, seus agentes e suas ações, bem
como é definida a sua arquitetura genérica. Posteriormente, é realizada uma classificação de si-
nais. Por fim, é apresentada uma arquitetura de sistemas de processamento digital. Nas seções
que se seguem, são apresentadas diversas listagens de programas, relativas a tais assuntos.
• O Código 2.2 apresenta uma relação entre os seguintes tipos de sinais: analógico sem
quantização, analógico quantizado, digital sem quantização e digital quantizado.
55
56 Capı́tulo 2. Conceitos básicos
22 end
end
24 end
%
26 % EOF
%
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % Demos para %
% A p o s t i l a de DSP %
13 % %
% Topico : t i p o s de s i n a i s %
15 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
17 % Modifs : 2022−1/2021−2/2011−02/2010−01/ %
% %
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
21
23 % lim p a ambiente
clear all
25 c l o s e a l l
27
% d e f i n e p ara met ros
29 A0 = 1 ;
F0 = 1 0 0 ;
31 T0 = 1/F0 ;
%
33 % numero de p e r i o d o s v i s u a l i z a d o s
NOP = 2 ;
35 %
% numero de p o n t o s por p e r i o d o para s i n a l a n a l o g i c o
37 PPPa = 1 0 0 0 ;
Tsa = T0/PPPa ;
39 t = 0 : Tsa : (NOP* T0 ) ;
%
41 % numero de p o n t o s por p e r i o d o para s i n a l amostrado
PPPs = 1 0 ;
43 Tss = T0/PPPs ;
nTs = 0 : Tss : (NOP* T0 ) ;
45 %
n = 0 : ( l e n g t h ( nTs ) − 1 ) ;
47
% constroi sinais
A.S.V.
2.2. Tipos de sinais 57
49 xa = A0 * c o s ( 2 * p i * F0 * t ) ; % sinal analogico
xs = A0 * c o s ( 2 * p i * F0 * nTs ) ; % s i n a l amostrado
51
53 % q u a n t i z a s i n a i s usando f u n c a o d e f i n i d a e x t e r n a m e n t e
%
55 % numero de i n t e r v a l o s do g r i d
NOI = 5 ;
57 % s i n a l a n a l o g i c o q u a n t i z a d o
xaq = q u a n t h a l f g r i d ( xa ,−A0 , ( A0/NOI ) , A0 ) ;
59 % s i n a l amostrado q u a n t i z a d o
xsq = q u a n t h a l f g r i d ( xs ,−A0 , ( A0/NOI ) , A0 ) ;
61
63 %
% desenha g r a f i c o s
65 %
67 %
figure (1)
69 %
% black = 0.0 ; gray suave = 0.8 ; white = 1.0
71 BCV = 1 . 0 ;
b a c k c o l o r = [BCV,BCV,BCV ] ;
73
%
75 % sem q u a n t i z a c a o
%
77 s u b p l o t ( 3 , 3 , 1 )
p l o t ( t , xa )
79 y l a b e l ( ’ x ( t ) ’ )
xlabel ( ’ t ( s ) ’ )
81 %
s e t ( gca , ’ C o l o r ’ , b a c k c o l o r )
83 t i t l e ( { ’ S i n a l a n a l ó g i c o : x ( t ) ’ , . . .
[ ’ T s= ’ , num2str (T0/PPPs ) , ’ s ’ , ’ ; ’ , ...
85 ’ Q { r e s }= ’ , num2str ( 1 /NOI ) ] } )
%
87 s u b p l o t ( 3 , 3 , 4 )
stem ( nTs , xs )
89 y l a b e l ( ’ x ( nT s ) ’ )
x l a b e l ( ’ nT s ( s ) ’ )
91 t i t l e ( { ’ S i n a l amostrado ’ , ’ x ( nT s ) = x ( t ) ; t = nT s ’ } )
%
93 s e t ( gca , ’ C o l o r ’ , b a c k c o l o r )
%
95 s u b p l o t ( 3 , 3 , 7 )
stem ( n , xs )
97 y l a b e l ( ’ x [ n ] ’ )
xlabel ( ’n ’ )
99 %
s e t ( gca , ’ C o l o r ’ , b a c k c o l o r )
101 t i t l e ( { ’ Sequ ê n c i a amostrada ’ , ’ x [ n ] = x ( nT s ) ’ } )
%
103 % com q u a n t i z a c a o
%
105 s u b p l o t ( 3 , 3 , 2 )
p l o t ( t , xa , ’ b ’ , t , xaq , ’ r ’ )
107 y l a b e l ( ’ \{ x ( t ) \ } Q ’ )
TET / UFF
58 Capı́tulo 2. Conceitos básicos
xlabel ( ’ t ( s ) ’ )
109 t i t l e ( { ’ S i n a l q u a n t i z a d o ’ , ’ \{ x ( t ) \ } Q ’ } )
%
111 s e t ( gca , ’ C o l o r ’ , b a c k c o l o r )
%
113 subplot (3 ,3 ,5)
% ’ f u n c i o n a , mas as c o r e s nao f ica m ok ! . . . ’
115 %stem ( nTs , [ x s ; x s q ] ’ )
h o l d on
117 stem ( nTs , xs , ’ bo− ’ )
stem ( nTs , xsq , ’ ro− ’ )
119 y l a b e l ( ’ \{ x ( nT s ) \ } Q ’ )
x l a b e l ( ’ nT s ( s ) ’ )
121 t i t l e ({ ’ S i n a l d i g i t a l ’ , . . .
’ \{ x ( nT s ) \ } Q = \{ x ( t ) \ } Q ; t = nT s ’ } )
123 %
s e t ( gca , ’ C o l o r ’ , b a c k c o l o r )
125 %
subplot (3 ,3 ,8)
127 % ’ f u n c i o n a , mas as c o r e s nao f ica m ok ! . . . ’
%stem ( n , [ x s ; x s q ] ’ )
129 h o l d on
stem ( n , xs , ’ bo− ’ )
131 stem ( n , xsq , ’ ro− ’ )
y l a b e l ( ’ \{ x [ n ] \ } Q ’ )
133 xlabel ( ’n ’ )
t i t l e ( { ’ Sequ ê n c i a d i g i t a l ’ , ’ \{ x [ n ] \ } Q = \{ x ( nT s ) \ } Q ’ } )
135 %
s e t ( gca , ’ C o l o r ’ , b a c k c o l o r )
137 %
% com q u a n t i z a c a o e n o r m a l i z a d o
139 %
subplot (3 ,3 ,3)
141 p l o t ( t , NOI* xa , ’ b ’ , t , NOI* xaq , ’ r ’ )
%
143 v = axis ;
v ( 3 ) = −NOI ;
145 v ( 4 ) = NOI ;
axis (v)
147 %
y l a b e l ( ’ \{ x ( t ) \ } {Qn} ’ )
149 xlabel ( ’ t ( s ) ’ )
t i t l e ( { ’ S i n a l q u a n t i z a d o n o r m a l i z a d o ’ , ’ \{ x ( t ) \ } {Qn} ’ } )
151 %
s e t ( gca , ’ C o l o r ’ , b a c k c o l o r )
153 %
subplot (3 ,3 ,6)
155 % ’ f u n c i o n a , mas as c o r e s nao f ica m ok ! . . . ’
%stem ( nTs , [ x s ; x s q ] ’ )
157 h o l d on
stem ( nTs , NOI* xs , ’ bo− ’ )
159 stem ( nTs , NOI* xsq , ’ ro− ’ )
%
161 v = axis ;
v ( 3 ) = −NOI ;
163 v ( 4 ) = NOI ;
axis (v)
165 %
y l a b e l ( ’ \{ x ( nT s ) \ } {Qn} ’ )
A.S.V.
2.3. Amostragem 59
167 x l a b e l ( ’ nT s ( s ) ’ )
t i t l e ({ ’ S i n a l d i g i t a l normalizado ’ , . . .
169 ’ \{ x ( nT s ) \ } {Qn} = \{ x ( t ) \ } {Qn} ; t = nT s ’ } )
%
171 s e t ( gca , ’ C o l o r ’ , b a c k c o l o r )
%
173 subplot (3 ,3 ,9)
% ’ f u n c i o n a , mas as c o r e s nao f ica m ok ! . . . ’
175 %stem ( n , [ x s ; x s q ] ’ )
h o l d on
177 stem ( n , NOI* xs , ’ bo− ’ )
stem ( n , NOI* xsq , ’ ro− ’ )
179 %
v = axis ;
181 v ( 3 ) = −NOI ;
v ( 4 ) = NOI ;
183 axis (v)
%
185 y l a b e l ( ’ \{ x [ n ] \ } {Qn} ’ )
xlabel ( ’n ’ )
187 t i t l e ( { ’ Sequ ê n c i a d i g i t a l n o r m a l i z a d a ’ , . . .
’ \{ x [ n ] \ } {Qn} = \{ x ( nT s ) \ } {Qn} ’ } )
189 %
s e t ( gca , ’ C o l o r ’ , b a c k c o l o r )
191
%%
2.3 Amostragem
• O Código 2.3 apresenta a geração de uma sequência discreta a partir de um sinal analógico.
• O Código 2.4 apresenta um exemplo que ilustra a influência do valor da taxa de amostra-
gem.
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Exemplo s o b r e %
10 % g e r a c a o de s e q u ê n c i a d i s c r e t a %
% a p a r t i r de s i n a l a n a l o g i c o %
12 % %
% Autor : A l e x a n d r e S . de l a Vega %
14 % Versao : 2018 2 %
% %
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TET / UFF
60 Capı́tulo 2. Conceitos básicos
20 %
clear all
22 c l o s e a l l
26
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
28
%
30 A0 = 1;
f0 = 1 e3 ; % f 0 = 1 kHz
32 p h i 0 = −p i / 4 ;
34 %
N0 = 10;
36 Omega0 = 2 * p i /N0 ;
38 %
Fs = N0 * f 0 ;
40
%
42 NOP = 3 ; % Nbr Of P e r i o d s
46
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
48
%
50 NOPPP = 1 0 0 ; % Nbr Pts Per P e r i o d
52 %
t min = 0 ;
54 t s t e p = ( 1 / ( f 0 *NOPPP) ) ;
t max = (NOP/ f 0 ) ;
56 %
t = t min : t s t e p : t max ;
58 %
xt = A0 * c o s ( 2 * p i * f 0 * t + p h i 0 ) ;
60
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
62
%
64 n min = 0;
n max = ( 3 * N0 ) ;
66 %
n = n min : n max ;
68 %
xn = A0 * c o s ( Omega0 * n + p h i 0 ) ;
70
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
72
76 %
FigNbr = 0 ;
A.S.V.
2.3. Amostragem 61
78 %
AmpSF = 1.25;
80 EfctAmp = (AmpSF* A0 ) ;
82 %%%%%%%%%% %%%%%%%%%%
84 %
FigNbr = FigNbr + 1 ;
86 h f=f i g u r e ( FigNbr ) ;
s e t ( hf , ”p a p e r t y p e ” , ”a4 ”)
88 %
p l o t ( t , xt , ’ k ’ )
90 v ( 2 ) = t max ;
v ( 3 ) = −EfctAmp ;
92 v ( 4 ) = EfctAmp ;
axis (v );
94 t i t l e ( ’ S i n a l a n a l ó g i c o ’ )
ylabel ( ’x( t ) ’ )
96 x l a b e l ( ’ t ( s ) ’ )
%
98
%%%%%%%%%% %%%%%%%%%%
100
%
102 FigNbr = FigNbr + 1 ;
h f=f i g u r e ( FigNbr ) ;
104 s e t ( hf , ”p a p e r t y p e ” , ”a4 ”)
%
106 p l o t ( t , xt , ’ k ’ )
h o l d on
108 stem ( n/Fs , xn , ’ r ’ )
%
110 v ( 2 ) = t max ;
v ( 3 ) = −EfctAmp ;
112 v ( 4 ) = EfctAmp ;
axis (v );
114 t i t l e ( ’ S i n a l a n a l ó g i c o e S i n a l a n a l ó g i c o amostrado ’ )
ylabel ( ’x( t ) e x ( nTs ) ’ )
116 x l a b e l ( ’ t ( s ) ’ )
%
118
%%%%%%%%%% %%%%%%%%%%
120
%
122 FigNbr = FigNbr + 1 ;
h f=f i g u r e ( FigNbr ) ;
124 s e t ( hf , ”p a p e r t y p e ” , ”a4 ”)
%
126 stem ( n/Fs , xn , ’ r ’ )
v(2) = t max ;
128 v ( 3 ) = −EfctAmp ;
v ( 4 ) = EfctAmp ;
130 a x i s ( v ) ;
t i t l e ( ’ S i n a l a n a l ó g i c o amostrado ’ )
132 y l a b e l ( ’ x ( nTs ) ’ )
x l a b e l ( ’ nTs ( s ) ’ )
134 %
TET / UFF
62 Capı́tulo 2. Conceitos básicos
138 %
FigNbr = FigNbr + 1 ;
140 h f=f i g u r e ( FigNbr ) ;
s e t ( hf , ”p a p e r t y p e ” , ”a4 ”)
142 %
stem ( n , xn , ’ b ’ )
144 v ( 2 ) = n max ;
v ( 3 ) = −EfctAmp ;
146 v ( 4 ) = EfctAmp ;
axis (v );
148 t i t l e ( ’ S i n a l d i s c r e t o ’ )
ylabel ( ’x [n] ’ )
150 x l a b e l ( ’ n ’ )
%
152
%%%%%%%%%% %%%%%%%%%%
154
%
156 FigNbr = FigNbr + 1 ;
h f=f i g u r e ( FigNbr ) ;
158 s e t ( hf , ”p a p e r t y p e ” , ”a4 ”)
%
160 s u b p l o t ( 4 , 1 , 1 )
p l o t ( t , xt , ’ k ’ )
162 v ( 2 ) = t max ;
v ( 3 ) = −EfctAmp ;
164 v ( 4 ) = EfctAmp ;
axis (v );
166 t i t l e ( ’ S i n a l a n a l ó g i c o ’ )
ylabel ( ’x( t ) ’ )
168 x l a b e l ( ’ t ( s ) ’ )
%
170 %
subplot (4 ,1 ,2)
172 p l o t ( t , xt , ’ k ’ )
h o l d on
174 stem ( n/Fs , xn , ’ r ’ )
%
176 v ( 2 ) = t max ;
v ( 3 ) = −EfctAmp ;
178 v ( 4 ) = EfctAmp ;
axis (v );
180 t i t l e ( ’ S i n a l a n a l ó g i c o e S i n a l a n a l ó g i c o amostrado ’ )
ylabel ( ’x( t ) e x ( nTs ) ’ )
182 x l a b e l ( ’ t ( s ) ’ )
%
184 %
subplot (4 ,1 ,3)
186 stem ( n/Fs , xn , ’ r ’ )
v(2) = t max ;
188 v ( 3 ) = −EfctAmp ;
v ( 4 ) = EfctAmp ;
190 a x i s ( v ) ;
t i t l e ( ’ S i n a l a n a l ó g i c o amostrado ’ )
192 y l a b e l ( ’ x ( nTs ) ’ )
x l a b e l ( ’ nTs ( s ) ’ )
194 %
%
A.S.V.
2.3. Amostragem 63
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % Exemplo s o b r e : %
% %
13 % − Sinal senoidal analogico . %
% − G r a f i c o ( da aproximacao ) de s i n a l a n a l o g i c o . %
15 % − Amostragem de s i n a l c o n t i n u o . %
% − S i n a l s e n o i d a l amostrado . %
17 % − G r a f i c o de s i n a l amostrado . %
% − Geracao de som por i n t e r p o l a c a o . %
19 % − I m p o r t a n c i a da t a x a de amostragem o r i g i n a l . %
% %
21 % Autor : A l e x a n d r e S . de l a Vega %
% %
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
25
%
27 % −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
%
29
% l i m p e z a do ambiente de t r a b a l h o
31 c l e a r a l l
close all
33
%
35 % −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
%
37
%
39 % Eh s u p o s t o um s i n a l s e n o i d a l a n a l o g i c o ,
% com a m p l i t u d e A, f r e q u e n c i a f ( Hz ) ou w ( rad / s )
TET / UFF
64 Capı́tulo 2. Conceitos básicos
41 % e a n g u l o de f a s e Theta ( rad ) .
%
43 % Eh d e f i n i d a uma f r e q u e n c i a de amostragem Fs=1/Ts ( Hz ) .
%
45 % Eh d e f i n i d a uma f r e q u e n c i a d i s c r e t a Omega=w* Ts ( rad ) .
%
47
%
49 % D e f i n i c o e s g e r a i s
%
51
% pa ra metro s do s i n a l a n a l o g i c o
53 A = 1 ;
%
55 f = 1 e3 ; % em H e r t z = 1/ segundo .
w = 2* p i * f ; % em rad / s .
57 %
Theta = 0 ; % em rad .
59
% f r e q u e n c i a de amostragem
61 Fs = 4 4 . 1 e3 ; % em H e r t z = 1/ segundo .
63 % pa ra metro s do s i n a l amostrado
Omega = w/ Fs ; % Omega = w* Ts ( rad )
65
%
67 % −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
%
69
%
71 % Eh d e f i n i d o um tempo t o t a l de g r a v a c a o Trec .
%
73 % Eh c a l c u l a d a a q u a n t i d a d e de amostras Nrec .
%
75 % Sao c a l c u l a d a s as amostras x r e c .
%
77
%
79 Trec = 2 ; % em s e g u n d o s .
%
81 % Nrec = f i x ( Trec /Ts ) + 1
% = f i x ( Trec * Fs ) + 1
83
%
85 Nrec = f i x ( Trec * Fs ) + 1 ;
87 %
n r e c = 0 : ( Nrec −1);
89 %
x r e c = A * c o s ( (Omega * n r e c ) + Theta ) ;
91
%
93 % −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
%
95
%
97 % Eh d e f i n i d o o tempo de 1 p e r i o d o f u n d a m e n t a l Tf=1/ f .
%
99 % Eh c a l c u l a d a a q u a n t i d a d e de amostras Nf .
A.S.V.
2.3. Amostragem 65
%
101 % Sao s e p a r a d a s as amostras x f a p a r t i r das amostras x r e c .
%
103
%
105 % Nf = f i x ( Tcos /Ts ) + 1
% = f i x ( Fs/ f c o s ) + 1
107 %
Nf = f i x ( Fs / f ) + 1 ;
109
%
111 n f = 0 : ( Nf −1);
%
113 %%%x f = A * c o s ( (Omega * n f ) + Theta ) ;
%
115 x f = x r e c ( 1 : Nf ) ;
117 %
% −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
119 %
121 %
% Sao r e a l i z a d o s d i v e r s o s g r a f i c o s
123 %
125 %
% Definicoes gerais
127 %
135 % c a l c u l a f a i x a de tempo de g r a v a c a o
%t r e c = ( n r e c / Fs ) ; % t = n * Ts ( s )
137
%
139 % −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
%
141
%
143 % Eh desenhado 1 p e r i o d o f u n d a m e n t a l
% ( da aproximacao ) do s i n a l a n a l o g i c o .
145 %
147 %
t e o s t r = ’ S i n a l s e n o i d a l a n a l ó g i c o : p e r ı́ odo fundamental . ’ ;
149 %
s i g n a l s t r = ’ x ( t ) = A cos ( (2 \ pi f t ) + \ Theta ) ’ ;
151 %
sep str = ’ ; ’;
153 %
param str = [ ’A = ’ , num2str (A)
];
155 p a r a m s t r = [ param str , s e p s t r , ’ f = ’ , num2str ( f ) , ’ ( Hz ) ’ ] ;
p a r a m s t r = [ param str , s e p s t r , ’ \ Theta = ’ , num2str ( Theta ) , ’ ( rad ) ’ ] ;
157 %
TET / UFF
66 Capı́tulo 2. Conceitos básicos
a n a t i t s t r = { t e o s t r , s i g n a l s t r , param str } ;
159
%
161 FigNbr = FigNbr + 1 ;
f i g u r e ( FigNbr )
163 %
p l o t ( t f , x f , ”k ”)
165 %
v = axis ;
167 v ( 2 ) = t f ( end ) ;
axis (v)
169 %
title ( ana tit str )
171 ylabel ( ’x ( t ) ’ )
xlabel ( ’ t ( s ) ’ )
173
% para t e s t e . . .
175 %r e t u r n
177 %
% −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
179 %
181 %
% Eh desenhado 1 p e r i o d o f u n d a m e n t a l
183 % do s i n a l amostrado com Fs .
%
185
%
187 t e o s t r = ’ S i n a l s e n o i d a l amostrado : p e r ı́ odo fundamental . ’ ;
%
189 s i g n a l s t r = ’ x ( nTs ) = A c o s ( ( 2 \ p i f n Ts ) + \ Theta ) ’ ;
%
191 s e p s t r = ’ ; ’;
%
193 p a r a m s t r = [ ’A = ’ , num2str (A)
];
p a r a m s t r = [ param str , s e p s t r , ’ f = ’ , num2str ( f ) , ’ ( Hz ) ’ ] ;
195 p a r a m s t r = [ param str , s e p s t r , ’ \ Theta = ’ , num2str ( Theta ) , ’ ( rad ) ’ ] ;
p a r a m s t r = [ param str , s e p s t r , ’ Ts = ’ , num2str ( 1 / Fs ) , ’ (s) ’
];
197 p a r a m s t r = [ param str , s e p s t r , ’ Fs = 1/Ts = ’ , num2str ( Fs ) , ’ ( Hz ) ’ ] ;
%
199 s m p t i t s t r = { t e o s t r , s i g n a l s t r , p a r a m s t r } ;
201 %
FigNbr = FigNbr + 1 ;
203 f i g u r e ( FigNbr )
%
205 stem ( t f , x f , ”k ”)
%
207 v = axis ;
v ( 2 ) = t f ( end ) ;
209 a x i s ( v )
%
211 t i t l e ( s m p t i t s t r )
y l a b e l ( ’ x ( n Ts ) ’ )
213 x l a b e l ( ’ n Ts ( s ) ’ )
A.S.V.
2.3. Amostragem 67
215 % para t e s t e . . .
%r e t u r n
217
%
219 % −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
%
221
%
223 % Eh desenhado 1 p e r i o d o f u n d a m e n t a l
% da s e q u e n c i a amostrada com Fs .
225 %
227 %
t e o s t r = ’ Sequ ê n c i a s e n o i d a l : p e r ı́ odo fundamental . ’ ;
229 %
s i g n a l s t r = ’ x [ n ] = A c o s ( ( ( 2 \ p i f Ts ) n ) + \ Theta ) ’ ;
231 s i g n a l s t r = [ s i g n a l s t r , ’ = A c o s ( ( \Omega n ) + \ Theta ) ’ ] ;
%
233 map str = ’ \Omega = \omega Ts = ( 2 \ p i f ) Ts ’ ;
%
235 s e p s t r = ’ ; ’;
%
237 p a r a m s t r = [ ’A = ’ , num2str (A)
];
p a r a m s t r = [ param str , s e p s t r , ’ f = ’ , num2str ( f ) , ’ ( Hz ) ’ ] ;
239 p a r a m s t r = [ param str , s e p s t r , ’ \ Theta = ’ , num2str ( Theta ) , ’ ( rad ) ’ ] ;
p a r a m s t r = [ param str , s e p s t r , ’ Ts = ’ , num2str ( 1 / Fs ) , ’ (s) ’
];
241 p a r a m s t r = [ param str , s e p s t r , ’ Fs = 1/Ts = ’ , num2str ( Fs ) , ’ ( Hz ) ’ ] ;
%
243 s e q t i t s t r = { t e o s t r , s i g n a l s t r , map str , p a r a m s t r } ;
245 %
FigNbr = FigNbr + 1 ;
247 f i g u r e ( FigNbr )
%
249 stem ( n f , x f , ”k ”)
%
251 v = axis ;
v ( 2 ) = n f ( end ) ;
253 a x i s ( v )
%
255 t i t l e ( s e q t i t s t r )
ylabel ( ’x [n] ’ )
257 x l a b e l ( ’ n ’ )
259 % para t e s t e . . .
%r e t u r n
261
%
263 % −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
%
265
%
267 % Eh desenhado 1 p e r i o d o f u n d a m e n t a l
% conjunto :
269 % ( da aproximacao ) do s i n a l a n a l o g i c o ,
% do s i n a l amostrado com Fs
271 % e
TET / UFF
68 Capı́tulo 2. Conceitos básicos
% da s e q u e n c i a amostrada com Fs .
273 %
275 %
FigNbr = FigNbr + 1 ;
277 f i g u r e ( FigNbr )
%
279 %
subplot (3 ,1 ,1)
281 %
p l o t ( t f , x f , ”k ”)
283 %
v = axis ;
285 v ( 2 ) = t f ( end ) ;
axis (v)
287 %
t i t l e ( { ’ Gera ç ã o de x ( n Ts ) por amostragem de x ( t ) . ’ ,
289 ’ Gera ç ã o de x [ n ] por i n d e x a ç ã o de x ( n Ts ) . ’ } )
%
291 y l a b e l ( ’ x ( t ) ’ )
xlabel ( ’ t ( s ) ’ )
293 %
%
295 s u b p l o t ( 3 , 1 , 2 )
%
297 stem ( t f , x f , ”k ”)
%
299 v = axis ;
v ( 2 ) = t f ( end ) ;
301 a x i s ( v )
%
303 y l a b e l ( ’ x ( n Ts ) ’ )
x l a b e l ( ’ n Ts ( s ) ’ )
305 %
%
307 s u b p l o t ( 3 , 1 , 3 )
%
309 stem ( n f , x f , ”k ”)
%
311 v = axis ;
v ( 2 ) = n f ( end ) ;
313 a x i s ( v )
%
315 y l a b e l ( ’ x [ n ] ’ )
xlabel ( ’n ’ )
317
% para t e s t e . . .
319 %r e t u r n
321 %
% −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
323 %
325 %
% Eh desenhado 1 p e r i o d o f u n d a m e n t a l
327 % conjunto :
% da r e c u p e r a c a o
329 % do s i n a l amostrado
% com Fs d i f e r e n t e s .
A.S.V.
2.3. Amostragem 69
331 %
333 %
FigNbr = FigNbr + 1 ;
335 f i g u r e ( FigNbr )
%
337 %
subplot (3 ,1 ,1)
339 %
stem ( t f , x f , ”k ”)
341 %
v = axis ;
343 v ( 2 ) = 2 * t f ( end ) ;
axis (v)
345 %
t i t l e ( ’ Gera ç ã o de x ( n Ts ) a p a r t i r de x [ n ] , empregando Fs = 1/Ts . ’ )
347 y l a b e l ( ’ x ( n Ts ) ’ )
%
349 %
subplot (3 ,1 ,2)
351 %
stem ( ( 2 * t f ) , x f , ”k ”)
353 %
v = axis ;
355 v ( 2 ) = 2 * t f ( end ) ;
axis (v)
357 %
t i t l e ( ’ Gera ç ã o de x ( n Ts ) a p a r t i r de x [ n ] , empregando ( Fs / 2 ) = 1 / ( 2 Ts ) . ’ )
359 y l a b e l ( ’ x ( n Ts ) ’ )
%
361 %
subplot (3 ,1 ,3)
363 %
stem ( ( 0 . 5 * t f ) , x f , ”k ”)
365 %
v = axis ;
367 v ( 2 ) = 2 * t f ( end ) ;
axis (v)
369 %
t i t l e ( ’ Gera ç ã o de x ( n Ts ) a p a r t i r de x [ n ] , empregando ( 2 Fs ) = 1 / ( Ts / 2 ) . ’ )
371 y l a b e l ( ’ x ( n Ts ) ’ )
%
373 x l a b e l ( ’ n Ts ( s ) ’ )
375 % para t e s t e . . .
%r e t u r n
377
%
379 % −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
%
381
%
383 % Eh desenhado 1 p e r i o d o f u n d a m e n t a l
% conjunto :
385 % da r e c u p e r a c a o
% do s i n a l a n a l o g i c o
387 % com Fs d i f e r e n t e s .
%
389
TET / UFF
70 Capı́tulo 2. Conceitos básicos
%
391 FigNbr = FigNbr + 1 ;
f i g u r e ( FigNbr )
393 %
%
395 subplot (3 ,1 ,1)
%
397 p l o t ( t f , x f , ”k ”)
%
399 v = axis ;
v ( 2 ) = 2 * t f ( end ) ;
401 axis (v)
%
403 t i t l e ( ’ Gera ç ã o de x ( t ) a p a r t i r de x [ n ] , empregando Fs = 1/Ts . ’ )
ylabel ( ’x ( t ) ’ )
405 %
%
407 subplot (3 ,1 ,2)
%
409 p l o t ( ( 2 * t f ) , x f , ”k ”)
%
411 v = axis ;
v ( 2 ) = 2 * t f ( end ) ;
413 axis (v)
%
415 t i t l e ( ’ Gera ç ã o de x ( t ) a p a r t i r de x [ n ] , empregando ( Fs / 2 ) = 1 / ( 2 Ts ) . ’ )
ylabel ( ’x ( t ) ’ )
417 %
%
419 subplot (3 ,1 ,3)
%
421 p l o t ( ( 0 . 5 * t f ) , x f , ”k ”)
%
423 v = axis ;
v ( 2 ) = 2 * t f ( end ) ;
425 axis (v)
%
427 t i t l e ( ’ Gera ç ã o de x ( t ) a p a r t i r de x [ n ] , empregando ( 2 Fs ) = 1 / ( Ts / 2 ) . ’ )
ylabel ( ’x ( t ) ’ )
429 %
xlabel ( ’ t ( s ) ’ )
431
% para t e s t e . . .
433 %r e t u r n
435 %
% −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
437 %
439 %
% Eh c o n s i d e r a d a a f r e q u e n c i a de amostragem Fs o r i g i n a l .
441 %
% Os v a l o r e s das amostras sao e n v i a d o s para a p l a c a de som .
443 %
% A p l a c a de som i n t e r p o l a os p o n t o s com Fs e g e r a o som .
445 %
%
447 % Sao g e r a d o s s o n s com Fs d i f e r e n t e s da Fs o r i g i n a l .
%
A.S.V.
2.3. Amostragem 71
449
%
451 d i s p l a y ( ”\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ”)
d i s p l a y ( ”\=============================================”)
453 d i s p l a y ( ”\=== Gera ç ã o de som a p a r t i r de a m o s tra s ===”)
d i s p l a y ( ”\=============================================”)
455 %
e s c o l h a = t o u p p e r ( i n p u t ( ”\ nDeseja g e r a r o som ( s /n ) ? [ s ] : ” , ”s ”) ) ;
457 i f ( e s c o l h a == ”N”)
d i s p l a y ( ”\n\n\n ”)
459 return
endif
461 %
d i s p l a y ( ”\n\n\n ”)
463 d i s p l a y ( ”\n\nSom para Fs o r i g i n a l . ”)
s ou n d s c ( x r e c , Fs )
465 %
d i s p l a y ( ”\ n P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ”)
467 pause
%
469 d i s p l a y ( ”\n\n\nSom para ( Fs / 2 ) = 1 / ( 2 Ts ) . ”)
s ou n d s c ( x r e c , ( Fs / 2 ) )
471 %
d i s p l a y ( ”\ n P r e s s i o n e q u a l q u e r t e c l a para c o n t i n u a r . . . ”)
473 pause
%
475 d i s p l a y ( ”\n\n\nSom para ( 2 Fs ) = 1 / ( Ts / 2 ) . ”)
s ou n d s c ( x r e c , ( 2 * Fs ) )
477 %
d i s p l a y ( ”\n\n\n ”)
479
%
481 % −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
%
483
%
485 % EOF
%
8 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % DSP − Aula 04/01/2016
%
12 % Autor : A l e x a n d r e S a n t o s de l a Vega
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 %
16 %
TET / UFF
72 Capı́tulo 2. Conceitos básicos
20 % e l i m i n a as v a r i v e i s de u s u a r i o , e x i s t e n t e s no a mbiente .
clear all
22
% e l i m i n a os g r a f i c o s c r i a d o s p e l o u s u a r i o , e x i s t e n t e s no ambiente .
24 c l o s e a l l
26 %
%%%%% %%%%% %%%%% %%%%% %%%%%
28 %
30 % d e f i n i c a o de p ara met ro s g e r a i s
%F0 = 1 e3 ;
32 %F0 = 4 . 4 e3 ;
%F0 = 10 e3 ;
34 F0 = 1 7 . 6 e3 ;
%
36 Fs = 44 e3 ;
%
38 T0 = 1/F0 ;
Ts = 1/ Fs ;
40 %
Trec = 12 * T0 ;
42 %
FigNbr = 0 ;
44
%
46 %%%%% %%%%% %%%%% %%%%% %%%%%
%
48
% s i m u l a c a o de s i n a l a n a l o g i c o
50 %
% d e f i n i c a o de p ar amet ro s
52 %
% Obs . : NPP = V eh e q u i v a l e n t e a Fs = V* F0 . . .
54 %
NumPtsPer = 2 0 0 ;
56 Tstep = T0 / NumPtsPer ;
nT = 0 : Tstep : ( Trec−Tstep ) ;
58 %
% d e f i n i c a o da f u n c a o
60 xa = c o s ( 2 * p i * F0 *nT ) ;
62 % grafico
FigNbr = FigNbr + 1 ;
64 f i g u r e ( FigNbr )
%
66 p l o t (nT , xa , ’ r ’ )
%
68 V = a x i s ;
a x i s ( [ V( 1 ) Tstep * l e n g t h ( xa ) V( 3 ) V ( 4 ) ] )
70 %
t i t l e ( ’ Simula ç ã o de curva a n a l ó g i c a ’ )
72 y l a b e l ( ’ x a ( t ) ’ )
xlabel ( ’ t ( s ) ’ )
74
%
A.S.V.
2.3. Amostragem 73
88 % g r a f i c o do s i n a l amostrado
FigNbr = FigNbr + 1 ;
90 f i g u r e ( FigNbr )
%
92 p l o t (nT , xa , ’ r ’ )
h o l d on
94 stem ( n * Ts , xd , ’ k ’ )
%
96 V = a x i s ;
a x i s ( [ V( 1 ) Tstep * l e n g t h ( xa ) V( 3 ) V ( 4 ) ] )
98 %
t i t l e ( ’ Simula ç ã o de amostragem : s i n a l o r i g i n a l e s i n a l amostrado ’ )
100 y l a b e l ( ’ x a ( t ) e x a ( n Ts ) ’ )
xlabel ( ’ t ( s ) ’ )
102 h o l d o f f
104 % g r a f i c o do s i n a l d i s c r e t o
FigNbr = FigNbr + 1 ;
106 f i g u r e ( FigNbr )
%
108 stem ( n , xd , ’ k ’ )
%
110 V = a x i s ;
a x i s ( [ V( 1 ) l e n g t h ( xd)−1 V( 3 ) V ( 4 ) ] )
112 %
t i t l e ( ’ Simula ç ã o de amostragem : s i n a l d i s c r e t o ’ )
114 y l a b e l ( ’ x [ n ] ’ )
xlabel ( ’n ’ )
116
%
118 %%%%% %%%%% %%%%% %%%%% %%%%%
%
120
% r e u n i a o de g r a f i c o s
122 %
FigNbr = FigNbr + 1 ;
124 f i g u r e ( FigNbr )
%
126 %
subplot (3 ,1 ,1)
128 p l o t (nT , xa , ’ r ’ )
%
130 V = a x i s ;
a x i s ( [ V( 1 ) Tstep * l e n g t h ( xa ) V( 3 ) V ( 4 ) ] )
132 %
t i t l e ( ’ Simula ç ã o de curva a n a l ó g i c a ’ )
134 y l a b e l ( ’ x a ( t ) ’ )
TET / UFF
74 Capı́tulo 2. Conceitos básicos
xlabel ( ’ t ( s ) ’ )
136 %
%
138 s u b p l o t ( 3 , 1 , 2 )
p l o t (nT , xa , ’ r ’ )
140 h o l d on
stem ( n * Ts , xd , ’ k ’ )
142 %
V = axis ;
144 a x i s ( [ V( 1 ) Tstep * l e n g t h ( xa ) V( 3 ) V ( 4 ) ] )
%
146 t i t l e ( ’ Simula ç ã o de amostragem : s i n a l o r i g i n a l e s i n a l amostrado ’ )
ylabel ( ’ x a ( t ) e x a ( n Ts ) ’ )
148 x l a b e l ( ’ t ( s ) ’ )
hold o f f
150 %
%
152 s u b p l o t ( 3 , 1 , 3 )
stem ( n , xd , ’ k ’ )
154 %
V = axis ;
156 a x i s ( [ V( 1 ) l e n g t h ( xd)−1 V( 3 ) V ( 4 ) ] )
%
158 t i t l e ( ’ Simula ç ã o de amostragem : s i n a l d i s c r e t o ’ )
ylabel ( ’x [n] ’ )
160 x l a b e l ( ’ n ’ )
162 %
% EOF
164 %
8 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % %
% Demos para %
12 % A p o s t i l a de DSP %
% %
14 % Topico : c a d e i a %
% de p r o c e s s a m e n t o d i g i t a l %
16 % de s i n a l a n a l o g i c o %
% %
18 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Modifs : /2010−1/2011−2/2022−1/ %
A.S.V.
2.4. Arquitetura de sistemas de processamento digital 75
20 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22 %
24
% lim p a ambiente
26 clear all
close all
28
30 %
% investiga interfaces graficas existentes
32 %a v a i l a b l e g r a p h i c s t o o l k i t s ( )
%
34 % i n v e s t i g a i n t e r f a c e g r a f i c a d e f a u l t
%g r a p h i c s t o o l k i t ( )
36 %
% experimenta d i f e r e n t e s i n t e r f a c e s g r a f i c a s
38 %g r a p h i c s t o o l k i t ( ” f l t k ”)
%g r a p h i c s t o o l k i t ( ” g n u p l o t ”)
40 %g r a p h i c s t o o l k i t ( ” q t ”)
%
42
44 % d e f i n e p ara met ro s
A0 = 1 ;
46 F0 = 1 e3 ;
T0 = 1/F0 ;
48 %
NOP = 2 ; % numero de p e r i o d o s v i s u a l i z a d o s
50 %
PPPa = 1 0 0 0 ; % numero de p o n t o s por p e r i o d o para s i n a l a n a l o g i c o
52 Tsa = T0/PPPa ;
t = 0 : Tsa : (NOP* T0 ) ;
54 %
PPPs = 1 0 ; % numero de p o n t o s por p e r i o d o para s i n a l amostrado
56 Tss = T0/PPPs ;
nTs = 0 : Tss : (NOP* T0 ) ;
58 %
n = 0 : ( l e n g t h ( nTs ) − 1 ) ;
60
62 % c o n s t r o i s i n a i s
xa = A0 * c o s ( 2 * p i * F0 * t ) ; % sinal analogico
64 xs = A0 * c o s ( 2 * p i * F0 * nTs ) ; % s i n a l amostrado
66
% q u a n t i z a s i n a i s usando f u n c a o d e f i n i d a e x t e r n a m e n t e
68 NOI = 5 ; % numero de i n t e r v a l o s do g r i d
xaq = q u a n t h a l f g r i d ( xa ,−A0 , ( A0/NOI ) , A0 ) ; % s i n a l a n a l o g i c o q u a n t i z a d o
70 xsq = q u a n t h a l f g r i d ( xs ,−A0 , ( A0/NOI ) , A0 ) ; % s i n a l amostrado q u a n t i z a d o
72
% desenha g r a f i c o s
74 %
back val = 1 . 0 ;
76
figure (1)
78 %
TET / UFF
76 Capı́tulo 2. Conceitos básicos
subplot (3 ,2 ,1)
80 p l o t ( t , xa , ’ k ’ )
s e t ( gca , ” c o l o r ” , [ b a c k v a l , b a c k v a l , b a c k v a l ] )
82 ylabel ( ’x( t ) ’ )
xlabel ( ’ t ( s ) ’ )
84 t i t l e ( { ’ S i n a l de e n t r a d a a n a l ó g i c o ’ , ’ ou ’ , . . .
’ S i n a l na s a ı́ da do f i l t r o a n t i −a l i a s i n g ’ } )
86 %
subplot (3 ,2 ,3)
88 p l o t ( t , xa , ’ k ’ )
h o l d on
90 f o r k = 1 : ( l e n g t h ( xs ) −1)
% stem ( nTs ( k ) , x s ( k ) , ’ : b ’ ) % nao f i c o u bom . . .
92 p l o t ( [ nTs ( k ) nTs ( k +1)] , [ xs ( k ) xs ( k ) ] , ’ b ’ )
p l o t ( [ nTs ( k+1) nTs ( k +1)] , [ xs ( k ) xs ( k +1)] , ’ b ’ )
94 end
s e t ( gca , ” c o l o r ” , [ b a c k v a l , b a c k v a l , b a c k v a l ] )
96 ylabel ( ’ r ( t ) ’ )
xlabel ( ’ t ( s ) ’ )
98 t i t l e ( ’ S i n a l na s a ı́ da do S/H ’ )
%
100 subplot (3 ,2 ,5)
p l o t ( t , xa , ’ k ’ )
102 h o l d on
f o r k = 1 : ( l e n g t h ( xs ) −1)
104 p l o t ( [ nTs ( k ) nTs ( k +1)] , [ xs ( k ) xs ( k ) ] , ’ b ’ )
p l o t ( [ nTs ( k+1) nTs ( k +1)] , [ xs ( k ) xs ( k +1)] , ’ b ’ )
106 end
f o r k = 1 : ( l e n g t h ( xsq ) −1)
108 p l o t ( [ nTs ( k ) nTs ( k +1)] , [ xsq ( k ) xsq ( k ) ] , ’ r ’ )
p l o t ( [ nTs ( k+1) nTs ( k +1)] , [ xsq ( k ) xsq ( k +1)] , ’ r ’ )
110 end
s e t ( gca , ” c o l o r ” , [ b a c k v a l , b a c k v a l , b a c k v a l ] )
112 ylabel ( ’c( t ) ’ )
xlabel ( ’ t ( s ) ’ )
114 t i t l e ( ’ S i n a l na s a ı́ da do ADC ’ )
%
116 subplot (3 ,2 ,2)
p l o t ( ( t * F0 * PPPs ) , xa , ’ k ’ )
118 h o l d on
stem ( n , xs , ’ k ’ )
120 stem ( n , xsq , ’ r ’ )
s e t ( gca , ” c o l o r ” , [ b a c k v a l , b a c k v a l , b a c k v a l ] )
122 ylabel ( ’ [ x [n] ] Q ’ )
xlabel ( ’n ’ )
124 t i t l e ( { ’ Sequ ê n c i a d i g i t a l de e n t r a d a ’ , ’ = ’ , . . .
’ Sequ ê n c i a d i g i t a l de s a ı́ da ’ } )
126 %
subplot (3 ,2 ,4)
128 stem ( n , xsq , ’ : r ’ )
h o l d on
130 f o r k = 1 : ( l e n g t h ( xsq ) −1)
plot ( [ n(k) n ( k +1)] , [ xsq ( k ) xsq ( k ) ] , ’ r ’ )
132 p l o t ( [ n ( k+1) n ( k +1)] , [ xsq ( k ) xsq ( k +1)] , ’ r ’ )
end
134 s e t ( gca , ” c o l o r ” , [ b a c k v a l , b a c k v a l , b a c k v a l ] )
ylabel ( ’c( t ) ’ )
136 xlabel ( ’ t ( s ) ’ )
t i t l e ( ’ S i n a l na s a ı́ da do DAC ’ )
A.S.V.
2.4. Arquitetura de sistemas de processamento digital 77
138 %
subplot (3 ,2 ,6)
140 p l o t ( t , xa , ’ k ’ )
h o l d on
142 p l o t ( nTs , xsq , ’ r ’ )
s e t ( gca , ” c o l o r ” , [ b a c k v a l , b a c k v a l , b a c k v a l ] )
144 y l a b e l ( ’ x ( t ) ’ )
xlabel ( ’ t ( s ) ’ )
146 t i t l e ( { ’ S i n a l na s a ı́ da do f i l t r o de smoothing ’ , ’ = ’ , . . .
’ S i n a l de s a ı́ da a n a l ó g i c o ’ } )
148
%
150 % EOF
%
TET / UFF
78 Capı́tulo 2. Conceitos básicos
A.S.V.
Parte II
79
Capı́tulo 3
3.1 Introdução
Na segunda parte do curso, são abordados os seguintes itens sobre sinais e sistemas (com
tempo discreto) no domı́nio do tempo: definições, classificações, exemplos e caracterizações de
sinais e sistemas. Além disso, são também abordados os seguintes tópicos sobre Sistema Linear
e Invariante ao Tempo (SLIT) com tempo discreto: caracterı́sticas, representações e cálculo de
resposta. Nas seções que se seguem, são apresentadas diversas listagens de programas, relativas
a tais assuntos.
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % Demos para %
% A p o s t i l a de DSP %
13 % %
% Topico : t i p o s de s e q u e n c i a s %
15 % s i s t e m a numerico %
% %
17 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Modifs : /2012−02/ %
19 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21 %
81
82 Capı́tulo 3. Sinais no domı́nio do tempo
23
% lim p a ambiente
25 clear all
close all
27
29 % c o n s t r o i s i n a i s
vr = [ 1 2 3 4 5 6 5 4 3 2 1]; % sinal real
31 wr = 4 * [ 1 1 1 0 0 0 0 0 −1 −1 −1]; % sinal real
%
33 xc = vr + j * wr ; % s i n a l complexo
35
% define indice
37 n = 0 : ( l e n g t h ( vr ) −1);
39
% desenha g r a f i c o s
41 %
% l e m b r e t e : AXIS ( [XMIN XMAX YMIN YMAX] ) ;
43 %
figure (1)
45 %
% sequencias reais
47 %
subplot (2 ,2 ,1)
49 stem ( n , vr , ’ k ’ )
ylabel ( ’ v r [n] ’ )
51 t i t l e ( ’ Sequ ê n c i a s r e a i s : v r [ n ] e w r [ n ] ’ )
v = axis ;
53 AXIS ( [ v ( 1 ) v ( 2 ) −6 6 ] ) ;
%
55 s u b p l o t ( 2 , 2 , 3 )
stem ( n , wr , ’ k ’ )
57 y l a b e l ( ’ w r [ n ] ’ )
xlabel ( ’n ’ )
59 v = a x i s ;
AXIS ( [ v ( 1 ) v ( 2 ) −6 6 ] ) ;
61 %
% s e q u e n c i a complexa
63 %
subplot (2 ,2 ,2)
65 stem ( n , abs ( xc ) , ’ b ’ )
ylabel ( ’ | x c [n] | ’ )
67 t i t l e ( ’ Sequ ê n c i a complexa : x c [ n ] = v r [ n ] + j \ cdot w r [ n ] ’ )
v = axis ;
69 AXIS ( [ v ( 1 ) v ( 2 ) −6 6 ] ) ;
%
71 s u b p l o t ( 2 , 2 , 4 )
stem ( n , a n g l e ( xc ) , ’ r ’ )
73 y l a b e l ( ’ \ a n g l e x c [ n ] ( rad ) ’ )
xlabel ( ’n ’ )
75 v = a x i s ;
AXIS ( [ v ( 1 ) v ( 2 ) −p i p i ] ) ;
77
79 %
% EOF
81 %
A.S.V.
3.2. Tipos de sequências 83
3.2.2 Comprimento
• O Código 3.2 apresenta exemplos de sequências com comprimento finito e infinito.
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % Demos para %
% A p o s t i l a de DSP %
13 % %
% Topico : t i p o s de s e q u e n c i a s %
15 % comprimento %
% %
17 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Modifs : /2012−02/ %
19 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21 %
23
% lim p a ambiente
25 clear all
close all
27
29 % c o n s t r o i s i n a i s
%
31 x f i n = [ 0 0 0 1 2 3 0 0 0 3 2 1 0 0 0];
%
33 xz = z e r o s ( 1 , 4 1 ) ;
%
35 x l d 1 = xz ;
x l d 1 ( 1 1 : end ) = 1 ;
37 %
x l d 2 = xz ;
39 x l d 2 ( 2 1 : end ) = 1 ;
%
41 x l d 3 = xz ;
x l d 3 ( 3 1 : end ) = 1 ;
43 %
xle1 = f l i p l r ( xld1 ) ;
45 x l e 2 = f l i p l r ( x l d 2 ) ;
xle3 = f l i p l r ( xld3 ) ;
47
49 % d e f i n e i n d i c e s
%
51 n f 1 = −20: −6;
n f 2 = −7:7;
53 n f 3 = 6:20;
TET / UFF
84 Capı́tulo 3. Sinais no domı́nio do tempo
%
55 ni = −20:20;
57
% desenha g r a f i c o s
59 %
% l e m b r e t e : AXIS ( [XMIN XMAX YMIN YMAX] ) ;
61 %
figure (1)
63 %
% s e q u e n c i a s de comprimento f i n i t o
65 %
subplot (3 ,1 ,1)
67 stem ( nf1 , x f i n , ’ k ’ )
t i t l e ( { ’ Sequ ê n c i a s de comprimento f i n i t o −− N = 15 ’ , . . .
69 ’ x 1 [ n ] = x 2 [ n+13] = x 3 [ n+26] ’ } )
ylabel ( ’ x 1 [n] ’ )
71 v = a x i s ;
a x i s ([ −20 20 v ( 3 ) v ( 4 ) ] ) ;
73 %
subplot (3 ,1 ,2)
75 stem ( nf2 , x f i n , ’ k ’ )
t i t l e ( ’ x 2 [ n ] = x 1 [ n−13] = x 3 [ n+13] ’ )
77 y l a b e l ( ’ x 2 [ n ] ’ )
v = axis ;
79 a x i s ([ −20 20 v ( 3 ) v ( 4 ) ] ) ;
%
81 s u b p l o t ( 3 , 1 , 3 )
stem ( nf3 , x f i n , ’ k ’ )
83 t i t l e ( ’ x 3 [ n ] = x 1 [ n−26] = x 2 [ n−13] ’ )
ylabel ( ’ x 3 [n] ’ )
85 x l a b e l ( ’ n ’ )
v = axis ;
87 a x i s ([ −20 20 v ( 3 ) v ( 4 ) ] ) ;
%
89 %
figure (2)
91 %
% s e q u e n c i a s de comprimento i n f i n i t o
93 %
%
95 % l a t e r a l esquerda
%
97 s u b p l o t ( 3 , 2 , 1 )
stem ( ni , x l e 1 , ’ k ’ )
99 t i t l e ( { ’ Sequ ê n c i a s de comprimento i n f i n i t o ’ , . . .
’ Lateral esquerda ’ })
101 y l a b e l ( ’ u [−n+10] ’ )
%
103 s u b p l o t ( 3 , 2 , 3 )
stem ( ni , x l e 2 , ’ k ’ )
105 t i t l e ( ’ L a t e r a l e s q u e r d a − A n t i c a u s a l ’ )
y l a b e l ( ’ u [−n ] ’ )
107 %
subplot (3 ,2 ,5)
109 stem ( ni , x l e 3 , ’ k ’ )
t i t l e ( ’ Lateral esquerda ’ )
111 y l a b e l ( ’ u [−n−10] ’ )
xlabel ( ’n ’ )
A.S.V.
3.2. Tipos de sequências 85
113 %
% lateral direita
115 %
subplot (3 ,2 ,2)
117 stem ( ni , xld1 , ’ k ’ )
t i t l e ( { ’ Sequ ê n c i a s de comprimento i n f i n i t o ’ , . . .
119 ’ Lateral d i r e i t a ’ })
y l a b e l ( ’ u [ n+10] ’ )
121 %
subplot (3 ,2 ,4)
123 stem ( ni , xld2 , ’ k ’ )
t i t l e ( ’ L a t e r a l d i r e i t a − Causal ’ )
125 y l a b e l ( ’ u [ n ] ’ )
%
127 s u b p l o t ( 3 , 2 , 6 )
stem ( ni , xld3 , ’ k ’ )
129 t i t l e ( ’ L a t e r a l d i r e i t a ’ )
y l a b e l ( ’ u [ n−10] ’ )
131 x l a b e l ( ’ n ’ )
133
%
135 % EOF
%
3.2.3 Simetria
• O Código 3.3 apresenta exemplos de simetria em sinais reais e complexos.
8 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % %
% Demos para %
12 % A p o s t i l a de DSP %
% %
14 % Topico : s i m e t r i a s %
% %
16 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Modifs : /2010−01/2011−02/ %
18 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 %
22
% lim p a ambiente
24 clear all
close all
26
TET / UFF
86 Capı́tulo 3. Sinais no domı́nio do tempo
32
% constroi sinais
34 xr = rand ( 1 ,N+1); % sequencia real
%
36 x r e = rand ( 1 ,N+1);
x im = rand ( 1 ,N+1);
38 xc = ( x r e + j * x im ) ; % s e q u e n c i a complexa
40
% c a l c u l a s e q u e n c i a s par e impar
42 x e = 0 . 5 * ( xr + f l i p l r ( xr ) ) ;
x o = 0 . 5 * ( xr − f l i p l r ( xr ) ) ;
44
46 % c a l c u l a s e q u e n c i a s c o n j u g a d a s i m e t r i c a e c o n j u g a d a a n t i −s i m e t r i c a
x c c s = 0 . 5 * ( xc + c o n j ( f l i p l r ( xc ) ) ) ;
48 x c c a = 0 . 5 * ( xc − c o n j ( f l i p l r ( xc ) ) ) ;
50
% desenha g r a f i c o s
52 %
figure (1)
54 %
% sequencia real
56 %
subplot (3 ,1 ,1)
58 stem ( n , xr )
ylabel ( ’x [n] ’ )
60 x l a b e l ( ’ n ’ )
t i t l e ( ’ Sequ ê n c i a r e a l : x [ n ] = x e [ n ] + x o [ n ] ’ )
62 %
subplot (3 ,1 ,2)
64 stem ( n , x e )
ylabel ( ’ x e [n] ’ )
66 x l a b e l ( ’ n ’ )
t i t l e ( ’ Sequ ê n c i a par : x e [ n ] ’ )
68 %
subplot (3 ,1 ,3)
70 stem ( n , x o )
ylabel ( ’ x o [n] ’ )
72 x l a b e l ( ’ n ’ )
t i t l e ( ’ Sequ ê n c i a ı́ mpar : x o [ n ] ’ )
74 %
%
76 f i g u r e ( 2 )
%
78 % s e q u e n c i a complexa
%
80 % modulo
%
82 s u b p l o t ( 3 , 2 , 1 )
stem ( n , r e a l ( xc ) )
84 y l a b e l ( ’ Re \{ x [ n ] \} ’ )
xlabel ( ’n ’ )
86 t i t l e ( ’ Parte r e a l da sequ ê n c i a complexa :
A.S.V.
3.2. Tipos de sequências 87
Re \{ x [ n ] \} = Re \{ x { c s } [ n ] + x { ca } [ n ] \} ’ )
88 %
subplot (3 ,2 ,3)
90 stem ( n , r e a l ( x c c s ) )
y l a b e l ( ’ Re \{ x { c s } [ n ] \} ’ )
92 x l a b e l ( ’ n ’ )
t i t l e ( ’ Parte r e a l da sequ ê n c i a conjugada sim é t r i c a :
94 Re \{ x { c s } [ n ] \} ’ )
%
96 s u b p l o t ( 3 , 2 , 5 )
stem ( n , r e a l ( x c c a ) )
98 y l a b e l ( ’ Re \{ x { ca } [ n ] \} ’ )
xlabel ( ’n ’ )
100 t i t l e ( ’ Parte r e a l da sequ ê n c i a conjugada a n t i −sim é t r i c a :
Re \{ x { ca } [ n ] \} ’ )
102 %
% a n g u l o de f a s e em g r a u s
104 %
subplot (3 ,2 ,2)
106 stem ( n , imag ( xc ) )
y l a b e l ( ’ Im \{ x [ n ] \} ’ )
108 x l a b e l ( ’ n ’ )
t i t l e ( ’ Parte imagin á r i a da sequ ê n c i a complexa :
110 Im \{ x [ n ] \} = Im \{ x { c s } [ n ] + x { ca } [ n ] \} ’ )
%
112 s u b p l o t ( 3 , 2 , 4 )
stem ( n , imag ( x c c s ) )
114 y l a b e l ( ’ Im \{ x { c s } [ n ] \} ’ )
xlabel ( ’n ’ )
116 t i t l e ( ’ Parte imagin á r i a da sequ ê n c i a conjugada sim é t r i c a :
Im \{ x { c s } [ n ] \} ’ )
118 %
subplot (3 ,2 ,6)
120 stem ( n , imag ( x c c a ) )
y l a b e l ( ’ Im \{ x { ca } [ n ] \} ’ )
122 x l a b e l ( ’ n ’ )
t i t l e ( ’ Parte imagin á r i a da sequ ê n c i a conjugada a n t i −sim é t r i c a :
124 Im \{ x { ca } [ n ] \} ’ )
126
%
128 % EOF
%
TET / UFF
88 Capı́tulo 3. Sinais no domı́nio do tempo
• O Código 3.9 e o Código 3.10 definem as sequências finitas que serão utilizadas no Có-
digo 3.13.
• O Código 3.11 e o Código 3.12 definem as sequências periódicas que serão utilizadas no
Código 3.13.
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % Demos para %
% A p o s t i l a de DSP %
13 % %
% Topico : d e s l o c a m e n t o c i r c u l a r %
15 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
17 % Modifs : /2010−01/2011−02/ %
% %
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
21
23 % lim p a ambiente
clear all
25 c l o s e a l l
27 N = 10;
n = 0 : ( N−1);
29
NDl = 3;
31 NDr = −3;
A.S.V.
3.3. Operações básicas sobre sequências 89
33 x = n;
35 k l = mod ( ( n+NDl ) ,N ) ;
y l = x ( k l +1);
37
kr = mod ( ( n+NDr ) ,N ) ;
39 yr = x ( kr +1);
41 figure (1)
%
43 subplot (2 ,1 ,1)
stem ( n , x , ’ b ’ )
45 h o l d on
stem ( n , yl , ’ r ’ )
47 y l a b e l ( ’ y [ n ] = x[<n+N D> N ] ’ )
xlabel ( ’n ’ )
49 t i t l e ( ’ Deslocamento c i r c u l a r : esquerda , com N D = 3 ’ )
legend ( ’x [ n ] ’ , ’y [ n ] ’ )
51 %
subplot (2 ,1 ,2)
53 stem ( n , x , ’ b ’ )
h o l d on
55 stem ( n , yr , ’ r ’ )
y l a b e l ( ’ y [ n ] = x[<n+N D> N ] ’ )
57 xlabel ( ’n ’ )
t i t l e ( ’ Deslocamento c i r c u l a r : d i r e i t a , com N D = −3 ’ )
59 legend ( ’x [ n ] ’ , ’y [ n ] ’ )
61 %
% EOF
63 %
TET / UFF
90 Capı́tulo 3. Sinais no domı́nio do tempo
8 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % %
% T i t u l o : Demo de d e s l o c a m e n t o s e %
12 % e s c a l a m e n t o s em t %
% %
14 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Datas : /2009−02/2011−01/ %
16 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18 %
20
% l i m p e z a do ambien te de t r a b a l h o
22 % v a r i a v e i s
clear all
24 % j a n e l a s
close all
26
36 % d e f i n i c a o das f u n c o e s
% nota : f u n c a o t e n d a d e f i n i d a em a r q u i v o t e n d a .m
38 Forg = tenda ( t ) ;
F l e f t = tenda ( t +5);
40 F r i g h t = tenda ( t −5);
Fcomp = tenda ( 2 * t ) ;
42 Fxpand = tenda ( t / 2 ) ;
Frx = tenda ( 2 * ( t − 5 ) ) ;
44 Fxr = tenda ( ( 2 * t ) −5);
46
% graficos
48 %
figure (1)
50 %
subplot (3 ,2 ,1)
52 p l o t ( t , Forg )
ylabel ( ’ f ( t ) ’ )
54 t i t l e ( ’ Deslocamentos em t ’ )
%
56 s u b p l o t ( 3 , 2 , 3 )
plot ( t , Fleft )
58 y l a b e l ( ’ f a ( t ) = f ( t+T D) ’ )
A.S.V.
3.3. Operações básicas sobre sequências 91
t i t l e ( ’ Avanç o : T D = 5 s ’ )
60 %
subplot (3 ,2 ,5)
62 p l o t ( t , F r i g h t )
y l a b e l ( ’ f d ( t ) = f ( t−T D) ’ )
64 t i t l e ( ’ Atraso : T D = 5 s ’ )
xlabel ( ’ t ( s ) ’ )
66 %
subplot (3 ,2 ,2)
68 p l o t ( t , Forg )
ylabel ( ’ f ( t ) ’ )
70 t i t l e ( ’ Esca lamento s em t ’ )
%
72 s u b p l o t ( 3 , 2 , 4 )
p l o t ( t , Fcomp )
74 y l a b e l ( ’ f c ( t ) = f ( t *K) ’ )
t i t l e ( ’ Compress ã o : K = 2 ’ )
76 %
subplot (3 ,2 ,6)
78 p l o t ( t , Fxpand )
y l a b e l ( ’ f e ( t ) = f ( t /K) ’ )
80 t i t l e ( ’ Expans ã o : K = 2 ’ )
xlabel ( ’ t ( s ) ’ )
82 %
figure (2)
84 %
subplot (3 ,1 ,1)
86 p l o t ( t , Forg )
ylabel ( ’ f ( t ) ’ )
88 t i t l e ( ’ Deslocamentos e e s c a l a m e n t o s em t ’ )
%
90 s u b p l o t ( 3 , 1 , 2 )
p l o t ( t , Frx )
92 y l a b e l ( ’ f { dc } ( t ) = f ( 2 * ( t−T D ) ) ’ )
t i t l e ( ’ Atraso s e g u i d o de compress ã o : K = 2 e T D = 5 s ’ )
94 %
subplot (3 ,1 ,3)
96 p l o t ( t , Fxr )
y l a b e l ( ’ f { cd } ( t ) = f ( ( 2 * t )−T D) ’ )
98 t i t l e ( ’ Compress ã o s e g u i d a de a t r a s o : K = 2 e T D = 5 s ’ )
xlabel ( ’ t ( s ) ’ )
100
%
102 % EOF
%
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TET / UFF
92 Capı́tulo 3. Sinais no domı́nio do tempo
% %
11 % T i t u l o : Demo de d e s l o c a m e n t o s e %
% e s c a l a m e n t o s em n %
13 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
15 % Datas : /2009−02/2011−01/ %
% %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
19
21 % l i m p e z a do ambien te de t r a b a l h o
% variaveis
23 c l e a r a l l
% janelas
25 c l o s e a l l
27
% d e f i n i c a o dos p ara met ro s
29 Tmin = −5;
Tmax = 2 5 ;
31 Step = 0 . 1 ;
%
33 t = Tmin : Step : Tmax ;
%
35 % c o n v e r s a o de tempo para i n d i c e
n = 0 : ( l e n g t h ( t ) −1);
37 n = n + ( Tmin/ Step ) ;
39
% d e f i n i c a o das f u n c o e s
41 % nota : f u n c a o t e n d a d e f i n i d a em a r q u i v o t e n d a .m
Forg = tenda ( t ) ;
43 F l e f t = tenda ( t +5);
F r i g h t = tenda ( t −5);
45 Fcomp = tenda ( 2 * t ) ;
Fxpand = tenda ( t / 2 ) ; % ’ i s s o r e p r e s e n t a up−s a m p l i n g + i n t e r p o l a c a o ! ! ! ’
47 Frx = tenda ( 2 * ( t − 5 ) ) ;
Fxr = tenda ( ( 2 * t ) −5);
49 %
% retirando a interpolacao . . .
51 F i n t e r p = Fxpand ;
Fxpand = z e r o s ( 1 , l e n g t h ( t ) ) ;
53 o d d i nd = 1 : 2 : l e n g t h ( t ) ;
Fxpand ( o d d i nd ) = F i n t e r p ( o dd i nd ) ;
55
57 % g r a f i c o s
%
59 f i g u r e ( 1 )
%
61 s u b p l o t ( 3 , 2 , 1 )
stem ( n , Forg )
63 y l a b e l ( ’ f [ n ] ’ )
t i t l e ( ’ Deslocamentos em n ’ )
65 %
subplot (3 ,2 ,3)
67 stem ( n , F l e f t )
y l a b e l ( ’ f a [ n ] = f [ n+N D ] ’ )
A.S.V.
3.3. Operações básicas sobre sequências 93
69 t i t l e ( ’ Avanç o : N D = 50 ’ )
%
71 subplot (3 ,2 ,5)
stem ( n , F r i g h t )
73 y l a b e l ( ’ f d [ n ] = f [ n−N D ] ’ )
t i t l e ( ’ Atraso : N D = 50 ’ )
75 xlabel ( ’n ’ )
%
77 subplot (3 ,2 ,2)
stem ( n , Forg )
79 ylabel ( ’ f [n] ’ )
t i t l e ( ’ Esca lamento s em n ’ )
81 %
subplot (3 ,2 ,4)
83 stem ( n , Fcomp )
y l a b e l ( ’ f { ds } [ n ] = f [ n *K] ’ )
85 t i t l e ( ’Down−s a m p l i n g : K = 2 ’ )
%
87 subplot (3 ,2 ,6)
stem ( n , Fxpand )
89 y l a b e l ( ’ f { us } [ n ] = f [ n/K] ’ )
t i t l e ( ’Up−s a m p l i n g : K = 2 ’ )
91 xlabel ( ’n ’ )
%
93 figure (2)
%
95 subplot (3 ,1 ,1)
stem ( n , Forg )
97 ylabel ( ’ f [n] ’ )
t i t l e ( ’ Deslocamentos e e s c a l a m e n t o s em n ’ )
99 %
subplot (3 ,1 ,2)
101 stem ( n , Frx )
y l a b e l ( ’ f { dds } [ n ] = f [K* ( n−N D ) ] ’ )
103 t i t l e ( ’ Atraso s e g u i d o de down−s a m p l i n g : K = 2 e N D = 50 ’ )
%
105 subplot (3 ,1 ,3)
stem ( n , Fxr )
107 y l a b e l ( ’ f { dsd } [ n ] = f [ (K* n)−N D ] ’ )
t i t l e ( ’Down−s a m p l i n g s e g u i d o de a t r a s o : K = 2 e N D = 50 ’ )
109 xlabel ( ’n ’ )
111 %
% EOF
113 %
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TET / UFF
94 Capı́tulo 3. Sinais no domı́nio do tempo
% %
11 % T i t u l o : Demo de d e s l o c a m e n t o l i n e a r %
% e %
13 % espelhamento c i r c u l a r %
% %
15 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Datas : /2012−01/ %
17 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19 %
21
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23 % l i m p e z a do ambien te de t r a b a l h o
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
% variaveis
27 c l e a r a l l
% janelas
29 c l o s e a l l
31
%%%%%%%%%%%%
33 % c a l c u l o s
%%%%%%%%%%%%
35
%
37 x = [ 2 ; 1 ; 2 ; −2; . . .
−1; −2; 1 ; 2 ; . . .
39 1 ; −1; −2; −1; . . .
2 ; 0 ; −2; −1; . . .
41 0 ; 1 ; −2; 0 ; . . .
2 ; 1 ; 0 ; −1];
43
%
45 N = 4 ;
Lx = l e n g t h ( x ) ;
47
%
49 xm = r e s h a p e ( x , N, ( Lx/N ) ) ;
51 %
ym = [ xm ; xm ( 1 , : ) ] ;
53 ym = f l i p u d (ym ) ;
ym = ym ( 1 : ( end − 1 ) , : ) ;
55
%
57 y = r e s h a p e (ym, Lx , 1 ) ;
59 %
nx = 0 : ( Lx −1);
61 nm = 0 : ( s i z e (xm, 1 ) − 1 ) ;
63
%%%%%%%%%%%
65 % f i g u r a s
%%%%%%%%%%%
67
%
A.S.V.
3.3. Operações básicas sobre sequências 95
69 Fig I n d = 0 ;
YlabelStrX = [ ’ x 0 [n] ’ ; ’x 1 [n] ’ ; ’x 2 [n] ’ ;
71 ’x 3 [n] ’ ; ’x 4 [n] ’ ; ’x 5 [n] ’ ];
YlabelStrY = [ ’ y 0 [n] ’ ; ’y 1 [n] ’ ; ’y 2 [n] ’ ;
73 ’y 3 [n] ’ ; ’y 4 [n] ’ ; ’y 5 [n] ’ ];
75 %
Fig I n d = F ig I nd + 1 ;
77 f i g u r e ( Fi g In d )
stem ( nx , x )
79 y l a b e l ( ’ x [ n ] ’ )
xlabel ( ’n ’ )
81
%
83 Fig I n d = F ig I nd + 1 ;
f i g u r e ( Fi g In d )
85 %
f o r SubInd = 1 : 6
87 s u b p l o t ( 2 , 3 , SubInd )
stem (nm, xm ( : , SubInd ) )
89 y l a b e l ( Y l a b e l S t r X ( SubInd , : ) )
xlabel ( ’n ’ )
91 AV = a x i s ;
a x i s ( [AV( 1 ) AV( 2 ) −2 2 ] ) ;
93 end
95 %
Fig I n d = F ig I nd + 1 ;
97 f i g u r e ( Fi g In d )
%
99 f o r SubInd = 1 : 6
s u b p l o t ( 2 , 3 , SubInd )
101 stem (nm, ym ( : , SubInd ) )
y l a b e l ( Y l a b e l S t r Y ( SubInd , : ) )
103 xlabel ( ’n ’ )
AV = a x i s ;
105 a x i s ( [AV( 1 ) AV( 2 ) −2 2 ] ) ;
end
107
%
109 Fig I n d = F ig I nd + 1 ;
f i g u r e ( Fi g In d )
111 stem ( nx , y )
ylabel ( ’y [n] ’ )
113 x l a b e l ( ’ n ’ )
115
%
117 % EOF
%
TET / UFF
96 Capı́tulo 3. Sinais no domı́nio do tempo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 %
function s = x seq ( t )
8
%
10 % x s e q Gera s e q u e n c i a f i n i t a x [ n ] .
%
12
% define o sinal
14 x0 = 1 ;
x1 = 2 ;
16 x2 = 2 ;
x3 = 1 ;
18 x4 = 0 ;
20 % g e r a s i n a l com i n d i c e s o r i g i n a i s
s t = ( x0 * ( t==0) + x1 * ( t==1) + x2 * ( t==2) + x3 * ( t==3) + x4 * ( t ==4));
22
% d e s c o b r e i n d i c e s nao d i s c r e t o s de t
24 n o t d i s c i n d = f i n d ( round ( t ) ˜= t ) ;
26 % i n d i c a i n d i c e s que d e v e r a o s e r i g n o r a d o s
s t ( n o t d i s c i n d ) = NaN;
28
% r e t o r n a s i n a l com i n d i c e s i n t e i r o s
30 s = s t ’ ;
32 %
% EOF
34 %
20 % g e r a s i n a l com i n d i c e s o r i g i n a i s
s t = ( h0 * ( t==0) + h1 * ( t==1) + h2 * ( t==2) + h3 * ( t==3) + h4 * ( t ==4));
22
% d e s c o b r e i n d i c e s nao d i s c r e t o s de t
24 n o t d i s c i n d = f i n d ( round ( t ) ˜= t ) ;
A.S.V.
3.3. Operações básicas sobre sequências 97
26 % i n d i c a i n d i c e s que d e v e r a o s e r i g n o r a d o s
s t ( n o t d i s c i n d ) = NaN;
28
% r e t o r n a s i n a l com i n d i c e s i n t e i r o s
30 s = s t ’ ;
32 %
% EOF
34 %
24 % r e t o r n a s i n a l com i n d i c e s i n t e i r o s
s = r e s h a p e ( vpd , (NoP* Nf ) , 1 ) ;
26
%
28 % EOF
%
9 %
% h seq per Gera s e q u e n c i a p e r i o d i c a h [ n ] .
TET / UFF
98 Capı́tulo 3. Sinais no domı́nio do tempo
11 %
13 % d e f i n e o s i n a l
n = 0 : ( Nf −1);
15 v = h s e q ( n ) ;
i f (NoP < 0 )
17 v = flipud (v );
v = c i r c s h i f t (v , 1 ) ;
19 NoP = −NoP ;
end
21 vp = [ v v v ] ;
vpd = c i r c s h i f t ( vp ,D) ;
23
% r e t o r n a s i n a l com i n d i c e s i n t e i r o s
25 s = r e s h a p e ( vpd , (NoP* Nf ) , 1 ) ;
27 %
% EOF
29 %
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % T i t u l o : Demo de r e l a c i o n a m e n t o %
% das c o n v o l u c o e s %
13 % linear , periodica e circular %
% %
15 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Datas : /2012−01/ %
17 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19 %
21
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23 % l i m p e z a do ambien te de t r a b a l h o
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
% variaveis
27 c l e a r a l l
% janelas
29 c l o s e a l l
31
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 % C o n s t a n t e s para g r a f i c o s
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
A.S.V.
3.3. Operações básicas sobre sequências 99
Fig I n d = 0 ;
37
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% C o n s t a n t e s para c o n v o l u c a o l i n e a r
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
43 N = 7 ;
D = 7;
45
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% x e h originais
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
51 Fig I n d = F ig I nd + 1 ;
f i g u r e ( Fi g In d )
53
%
55 n = 0 : ( N−1);
57 %
xn = x s e q ( n ) ;
59 %
subplot (2 ,1 ,1)
61 stem ( n , xn )
t i t l e ( ’ Entrada ’ )
63 y l a b e l ( ’ x [ n ] ’ )
xlabel ( ’n ’ )
65
%
67 hn = h s e q ( n ) ;
%
69 s u b p l o t ( 2 , 1 , 2 )
stem ( n , hn )
71 t i t l e ( ’ Resposta ao i m p u l s o ’ )
ylabel ( ’h [ n ] ’ )
73 x l a b e l ( ’ n ’ )
75
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 % x e s p e l h a d o s e d e s l o c a d o s
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 %
Fig I n d = F ig I nd + 1 ;
81 f i g u r e ( Fi g In d )
83 %
Y l a b e l S t r X = [ ’ x[−k ] ’ ; ’ x[−k+1] ’ ; ’ x[−k+2] ’ ;
85 ’ x[−k+3] ’ ; ’ x[−k+4] ’ ; ’ x[−k+5] ’ ;
’ x[−k+6] ’
87 ];
k = −(D− 1 ) : (D−1);
89
%
91 xk = x s e q ( k ) ;
%
93 s u b p l o t ( 2 , 4 , 1 )
stem ( k , xk )
TET / UFF
100 Capı́tulo 3. Sinais no domı́nio do tempo
95 t i t l e ( ’ Entrada ’ )
ylabel ( ’x [ k ] ’ )
97 x l a b e l ( ’ k ’ )
AV = a x i s ;
99 a x i s ([ −6 6 0 2 ] ) ;
101 %
mxd = [ ] ;
103 f o r d = 0 : ( D−1)
mxd = [ mxd x s e q (−k + d ) ] ;
105 end
%
107 f o r SubInd = 0 : ( D−1)
s u b p l o t ( 2 , 4 , ( SubInd +2))
109 stem ( k , mxd ( : , ( SubInd +1)))
y l a b e l ( Y l a b e l S t r X ( ( SubInd + 1 ) , : ) )
111 xlabel ( ’k ’ )
AV = a x i s ;
113 a x i s ([ −6 6 0 2 ] ) ;
end
115
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% h espelhados e deslocados
119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
121 Fig I n d = F ig I nd + 1 ;
f i g u r e ( Fig I n d )
123
%
125 Y l a b e l S t r H = [ ’ h[−k ] ’ ; ’ h[−k+1] ’ ; ’ h[−k+2] ’ ;
’ h[−k+3] ’ ; ’ h[−k+4] ’ ; ’ h[−k+5] ’ ;
127 ’ h[−k+6] ’
];
129 k = −(D− 1 ) : (D−1);
131 %
hk = h s e q ( k ) ;
133 %
subplot (2 ,4 ,1)
135 stem ( k , hk )
t i t l e ( ’ Resposta ao i m p u l s o ’ )
137 y l a b e l ( ’ h [ k ] ’ )
xlabel ( ’k ’ )
139 AV = a x i s ;
a x i s ([ −6 6 0 2 ] ) ;
141
%
143 mhd = [ ] ;
f o r d = 0 : ( D−1)
145 mhd = [ mhd h s e q (−k + d ) ] ;
end
147
%
149 f o r SubInd = 0 : ( D−1)
s u b p l o t ( 2 , 4 , ( SubInd +2))
151 stem ( k , mhd ( : , ( SubInd +1)))
y l a b e l ( Y l a b e l S t r H ( ( SubInd + 1 ) , : ) )
153 xlabel ( ’k ’ )
A.S.V.
3.3. Operações básicas sobre sequências 101
AV = a x i s ;
155 a x i s ([ −6 6 0 2 ] ) ;
end
157
159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% c o n v o l u c a o l i n e a r de x com h e s p e l h a d o s e d e s l o c a d o s
161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
163 Fig I n d = F ig I nd + 1 ;
f i g u r e ( Fi g In d )
165
%
167 YlabelStrXHd = [ ’ x [ k ] \ c d o t h[−k ] ’ ; ’ x [ k ] \ c d o t h[−k+1] ’ ;
’ x [ k ] \ c d o t h[−k+2] ’ ; ’ x [ k ] \ c d o t h[−k+3] ’ ;
169 ’ x [ k ] \ c d o t h[−k+4] ’ ; ’ x [ k ] \ c d o t h[−k+5] ’ ;
’ x [ k ] \ c d o t h[−k+6] ’
171 ];
k = −(D− 1 ) : (D−1);
173
%
175 myxhd = [ ] ;
f o r i n d = 1 :D
177 myxhd = [ myxhd ( xk . * mhd ( : , i n d ) ) ] ;
end
179 %
f o r SubInd = 0 : ( D−1)
181 s u b p l o t ( 2 , 4 , ( SubInd +1))
stem ( k , myxhd ( : , ( SubInd +1)))
183 y l a b e l ( YlabelStrXHd ( ( SubInd + 1 ) , : ) )
xlabel ( ’k ’ )
185 AV = a x i s ;
a x i s ([ −6 6 0 6 ] ) ;
187 end
189 %
y = [];
191 f o r i n d = 1 :D
y = [ y sum ( myxhd ( : , i n d ) ) ] ;
193 end
%
195 s u b p l o t ( 2 , 4 , 8 )
stem ( n , y )
197 t i t l e ( ’ Convolu ç ã o l i n e a r ’ )
ylabel ( ’y L [n] ’ )
199 x l a b e l ( ’ n ’ )
AV = a x i s ;
201 a x i s ([ −6 6 0 6 ] ) ;
%
203
205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% c o n v o l u c a o l i n e a r de h com x e s p e l h a d o s e d e s l o c a d o s
207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
209 Fig I n d = F ig I nd + 1 ;
f i g u r e ( Fi g In d )
211
%
TET / UFF
102 Capı́tulo 3. Sinais no domı́nio do tempo
235 %
y = [];
237 f o r i n d = 1 :D
y = [ y sum ( myhxd ( : , i n d ) ) ] ;
239 end
%
241 s u b p l o t ( 2 , 4 , 8 )
stem ( n , y )
243 t i t l e ( ’ Convolu ç ã o l i n e a r ’ )
ylabel ( ’y L [n] ’ )
245 x l a b e l ( ’ n ’ )
AV = a x i s ;
247 a x i s ([ −6 6 0 6 ] ) ;
%
249
251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% C o n s t a n t e s para c o n v o l u c a o p e r i o d i c a
253 % com numero i n s u f i c i e n t e de amostras
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
255 %
Np = 4 ;
257
259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% x e h periodicos
261 % Np = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
263 %
Fig I n d = F ig I nd + 1 ;
265 f i g u r e ( Fig I n d )
267 %
np = −Np : ( 2 * Np − 1 ) ;
269 RedLine = (Np+ 1 ) : ( 2 * Np ) ;
NoP = 3 ;
271
A.S.V.
3.3. Operações básicas sobre sequências 103
%
273 xpn = x s e q p e r (Np, 0 , NoP ) ;
%
275 subplot (2 ,1 ,1)
stem ( np , xpn )
277 h o l d on
stem ( np ( RedLine ) , xpn ( RedLine ) , ’ r ’ )
279 t i t l e ( ’ Entrada p e r i ó d i c a ’ )
ylabel ( ’x p [n] ’ )
281 xlabel ( ’n ’ )
283 %
hpn = h s e q p e r (Np, 0 , NoP ) ;
285 %
subplot (2 ,1 ,2)
287 stem ( np , hpn )
h o l d on
289 stem ( np ( RedLine ) , hpn ( RedLine ) , ’ r ’ )
t i t l e ( ’ Resposta ao i m p u l s o p e r i ó d i c a ’ )
291 y l a b e l ( ’ h p [ n ] ’ )
xlabel ( ’n ’ )
293
295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% x periodicos espelhados e deslocados
297 % Np = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
299 %
Fig I n d = F ig I nd + 1 ;
301 f i g u r e ( Fi g In d )
303 %
YlabelStrXp = [ ’ x p [−k ] ’ ; ’ x p [−k+1] ’ ; ’ x p [−k+2] ’ ;
305 ’ x p [−k+3] ’
];
307 k = np ;
309 %
xpk = xpn ;
311 %
subplot (2 ,3 ,1)
313 stem ( np , xpk )
h o l d on
315 stem ( np ( RedLine ) , xpk ( RedLine ) , ’ r ’ )
t i t l e ( ’ Entrada p e r i ó d i c a ’ )
317 y l a b e l ( ’ x p [ k ] ’ )
xlabel ( ’k ’ )
319 AV = a x i s ;
a x i s ([ −Np ( 2 * Np − 1 ) 0 2 ] ) ;
321
%
323 NoP = −3;
mxpd = [ ] ;
325 f o r d = 0 : ( Np−1)
mxpd = [ mxpd x s e q p e r (Np , d , NoP ) ] ;
327 end
%
329 f o r SubInd = 0 : ( Np−1)
s u b p l o t ( 2 , 3 , ( SubInd +2))
TET / UFF
104 Capı́tulo 3. Sinais no domı́nio do tempo
341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% h periodicos espelhados e deslocados
343 % Np = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
345 %
Fig I n d = F ig I nd + 1 ;
347 f i g u r e ( Fig I n d )
349 %
YlabelStrHp = [ ’ h p [−k ] ’ ; ’ h p [−k+1] ’ ; ’ h p [−k+2] ’ ;
351 ’ h p [−k+3] ’
];
353 k = np ;
355 %
hpk = hpn ;
357 %
subplot (2 ,3 ,1)
359 stem ( np , hpk )
h o l d on
361 stem ( np ( RedLine ) , hpk ( RedLine ) , ’ r ’ )
t i t l e ( ’ Resposta ao i m p u l s o p e r i ó d i c a ’ )
363 y l a b e l ( ’ h p [ k ] ’ )
xlabel ( ’k ’ )
365 AV = a x i s ;
a x i s ([ −Np ( 2 * Np − 1 ) 0 2 ] ) ;
367
%
369 NoP = −3;
mhpd = [ ] ;
371 f o r d = 0 : ( Np−1)
mhpd = [ mhpd h s e q p e r (Np , d , NoP ) ] ;
373 end
%
375 f o r SubInd = 0 : ( Np−1)
s u b p l o t ( 2 , 3 , ( SubInd +2))
377 stem ( k , mhpd ( : , ( SubInd +1)))
h o l d on
379 stem ( k ( RedLine ) , mhpd( RedLine , ( SubInd +1)) , ’ r ’ )
y l a b e l ( YlabelStrHp ( ( SubInd + 1 ) , : ) )
381 xlabel ( ’k ’ )
AV = a x i s ;
383 a x i s ([ −Np ( 2 * Np − 1 ) 0 2 ] ) ;
end
385
387 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% c o n v o l u c a o p e r i o d i c a de x com h e s p e l h a d o s e d e s l o c a d o s
389 % Np = 4
A.S.V.
3.3. Operações básicas sobre sequências 105
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
391 %
Fig I n d = F ig I nd + 1 ;
393 f i g u r e ( Fi g In d )
395 %
YlabelStrXpHpd = [ ’ x p [ k ] \ c d o t h p [−k ] ’ ; ’ x p [ k ] \ c d o t h p [−k+1] ’ ;
397 ’ x p [ k ] \ c d o t h p [−k+2] ’ ; ’ x p [ k ] \ c d o t h p [−k+3] ’
];
399 k = 0 : ( Np−1);
kind = k+1;
401
%
403 myxphpd = [ ] ;
f o r i n d = 1 : Np
405 myxphpd = [ myxphpd ( xpk ( kind ) . * mhpd( kind , i n d ) ) ] ;
end
407 %
f o r SubInd = 0 : ( Np−1)
409 s u b p l o t ( 2 , 4 , ( SubInd +1))
stem ( k , myxphpd ( kind , ( SubInd +1)))
411 y l a b e l ( YlabelStrXpHpd ( ( SubInd + 1 ) , : ) )
xlabel ( ’k ’ )
413 AV = a x i s ;
a x i s ( [ 0 (Np − 1 ) 0 6 ] ) ;
415 end
417 %
y = [];
419 f o r i n d = 1 : Np
y = [ y sum ( myxphpd ( kind , i n d ) ) ] ;
421 end
%
423 s u b p l o t ( 2 , 4 , ( Np+4))
stem ( k , y )
425 t i t l e ( ’ Convolu ç ã o p e r i ó d i c a ( N p = 4 ) ’ )
ylabel ( ’y p [n] ’ )
427 x l a b e l ( ’ n ’ )
AV = a x i s ;
429 a x i s ( [ 0 (Np − 1 ) 0 6 ] ) ;
%
431
433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% c o n v o l u c a o p e r i o d i c a de h com x e s p e l h a d o s e d e s l o c a d o s
435 % Np = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
437 %
Fig I n d = F ig I nd + 1 ;
439 f i g u r e ( Fi g In d )
441 %
YlabelStrHpXpd = [ ’ h p [ k ] \ c d o t x p [−k ] ’ ; ’ h p [ k ] \ c d o t x p [−k+1] ’ ;
443 ’ h p [ k ] \ c d o t x p [−k+2] ’ ; ’ h p [ k ] \ c d o t x p [−k+3] ’
];
445 k = 0 : ( Np−1);
kind = k+1;
447
%
TET / UFF
106 Capı́tulo 3. Sinais no domı́nio do tempo
449 myhpxpd = [ ] ;
f o r i n d = 1 : Np
451 myhpxpd = [ myhpxpd ( hpk ( kind ) . * mxpd( kind , i n d ) ) ] ;
end
453 %
f o r SubInd = 0 : ( Np−1)
455 s u b p l o t ( 2 , 4 , ( SubInd +1))
stem ( k , myhpxpd ( kind , ( SubInd +1)))
457 y l a b e l ( YlabelStrHpXpd ( ( SubInd + 1 ) , : ) )
xlabel ( ’k ’ )
459 AV = a x i s ;
a x i s ( [ 0 (Np − 1 ) 0 6 ] ) ;
461 end
463 %
y = [];
465 f o r i n d = 1 : Np
y = [ y sum ( myhpxpd ( kind , i n d ) ) ] ;
467 end
%
469 s u b p l o t ( 2 , 4 , ( Np+4))
stem ( k , y )
471 t i t l e ( ’ Convolu ç ã o p e r i ó d i c a ( N p = 4 ) ’ )
ylabel ( ’y p [n] ’ )
473 x l a b e l ( ’ n ’ )
AV = a x i s ;
475 a x i s ( [ 0 (Np − 1 ) 0 6 ] ) ;
%
477
479 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% C o n s t a n t e s para c o n v o l u c a o p e r i o d i c a
481 % com numero s u f i c i e n t e de amostras
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
483 %
Np = 6 ;
485
487 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% x e h periodicos
489 % Np = 6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
491 %
Fig I n d = F ig I nd + 1 ;
493 f i g u r e ( Fig I n d )
495 %
np = −Np : ( 2 * Np − 1 ) ;
497 RedLine = (Np+ 1 ) : ( 2 * Np ) ;
NoP = 3 ;
499
%
501 xpn = x s e q p e r (Np, 0 , NoP ) ;
%
503 s u b p l o t ( 2 , 1 , 1 )
stem ( np , xpn )
505 h o l d on
stem ( np ( RedLine ) , xpn ( RedLine ) , ’ r ’ )
507 t i t l e ( ’ Entrada p e r i ó d i c a ’ )
A.S.V.
3.3. Operações básicas sobre sequências 107
ylabel ( ’x p [n] ’ )
509 xlabel ( ’n ’ )
511 %
hpn = h s e q p e r (Np, 0 , NoP ) ;
513 %
subplot (2 ,1 ,2)
515 stem ( np , hpn )
h o l d on
517 stem ( np ( RedLine ) , hpn ( RedLine ) , ’ r ’ )
t i t l e ( ’ Resposta ao i m p u l s o p e r i ó d i c a ’ )
519 y l a b e l ( ’ h p [ n ] ’ )
xlabel ( ’n ’ )
521
523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% x periodicos espelhados e deslocados
525 % Np = 6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
527 %
Fig I n d = F ig I nd + 1 ;
529 f i g u r e ( Fi g In d )
531 %
YlabelStrXp = [ ’ x p [−k ] ’ ; ’ x p [−k+1] ’ ; ’ x p [−k+2] ’ ;
533 ’ x p [−k+3] ’ ; ’ x p [−k+4] ’ ; ’ x p [−k+5] ’
];
535 k = np ;
537 %
xpk = xpn ;
539 %
subplot (2 ,4 ,1)
541 stem ( np , xpk )
h o l d on
543 stem ( np ( RedLine ) , xpk ( RedLine ) , ’ r ’ )
t i t l e ( ’ Entrada p e r i ó d i c a ’ )
545 y l a b e l ( ’ x p [ k ] ’ )
xlabel ( ’k ’ )
547 AV = a x i s ;
a x i s ([ −Np ( 2 * Np − 1 ) 0 2 ] ) ;
549
%
551 NoP = −3;
mxpd = [ ] ;
553 f o r d = 0 : ( Np−1)
mxpd = [ mxpd x s e q p e r (Np , d , NoP ) ] ;
555 end
%
557 f o r SubInd = 0 : ( Np−1)
s u b p l o t ( 2 , 4 , ( SubInd +2))
559 stem ( k , mxpd ( : , ( SubInd +1)))
h o l d on
561 stem ( k ( RedLine ) , mxpd( RedLine , ( SubInd +1)) , ’ r ’ )
y l a b e l ( YlabelStrXp ( ( SubInd + 1 ) , : ) )
563 xlabel ( ’k ’ )
AV = a x i s ;
565 a x i s ([ −Np ( 2 * Np − 1 ) 0 2 ] ) ;
end
TET / UFF
108 Capı́tulo 3. Sinais no domı́nio do tempo
567
569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% h periodicos espelhados e deslocados
571 % Np = 6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
573 %
Fig I n d = F ig I nd + 1 ;
575 f i g u r e ( Fig I n d )
577 %
YlabelStrHp = [ ’ h p [−k ] ’ ; ’ h p [−k+1] ’ ; ’ h p [−k+2] ’ ;
579 ’ h p [−k+3] ’ ; ’ h p [−k+4] ’ ; ’ h p [−k+5] ’
];
581 k = np ;
583 %
hpk = hpn ;
585 %
subplot (2 ,4 ,1)
587 stem ( np , hpk )
h o l d on
589 stem ( np ( RedLine ) , hpk ( RedLine ) , ’ r ’ )
t i t l e ( ’ Resposta ao i m p u l s o p e r i ó d i c a ’ )
591 y l a b e l ( ’ h p [ k ] ’ )
xlabel ( ’k ’ )
593 AV = a x i s ;
a x i s ([ −Np ( 2 * Np − 1 ) 0 2 ] ) ;
595
%
597 NoP = −3;
mhpd = [ ] ;
599 f o r d = 0 : ( Np−1)
mhpd = [ mhpd h s e q p e r (Np , d , NoP ) ] ;
601 end
%
603 f o r SubInd = 0 : ( Np−1)
s u b p l o t ( 2 , 4 , ( SubInd +2))
605 stem ( k , mhpd ( : , ( SubInd +1)))
h o l d on
607 stem ( k ( RedLine ) , mhpd( RedLine , ( SubInd +1)) , ’ r ’ )
y l a b e l ( YlabelStrHp ( ( SubInd + 1 ) , : ) )
609 xlabel ( ’k ’ )
AV = a x i s ;
611 a x i s ([ −Np ( 2 * Np − 1 ) 0 2 ] ) ;
end
613
615 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% c o n v o l u c a o p e r i o d i c a de x com h e s p e l h a d o s e d e s l o c a d o s
617 % Np = 6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 %
Fig I n d = F ig I nd + 1 ;
621 f i g u r e ( Fig I n d )
623 %
YlabelStrXpHpd = [ ’ x p [ k ] \ c d o t h p [−k ] ’ ; ’ x p [ k ] \ c d o t h p [−k+1] ’ ;
625 ’ x p [ k ] \ c d o t h p [−k+2] ’ ; ’ x p [ k ] \ c d o t h p [−k+3] ’ ;
A.S.V.
3.3. Operações básicas sobre sequências 109
’ x p [ k ] \ c d o t h p [−k+4] ’ ; ’ x p [ k ] \ c d o t h p [−k+5] ’
627 ];
k = 0 : ( Np−1);
629 kind = k+1;
631 %
myxphpd = [ ] ;
633 f o r i n d = 1 : Np
myxphpd = [ myxphpd ( xpk ( kind ) . * mhpd( kind , i n d ) ) ] ;
635 end
%
637 f o r SubInd = 0 : ( Np−1)
s u b p l o t ( 2 , 4 , ( SubInd +1))
639 stem ( k , myxphpd ( kind , ( SubInd +1)))
y l a b e l ( YlabelStrXpHpd ( ( SubInd + 1 ) , : ) )
641 xlabel ( ’k ’ )
AV = a x i s ;
643 a x i s ( [ 0 (Np − 1 ) 0 6 ] ) ;
end
645
%
647 y = [ ] ;
f o r i n d = 1 : Np
649 y = [ y sum ( myxphpd ( kind , i n d ) ) ] ;
end
651 %
s u b p l o t ( 2 , 4 , ( Np+2))
653 stem ( k , y )
t i t l e ( ’ Convolu ç ã o p e r i ó d i c a ( N p = 6 ) ’ )
655 y l a b e l ( ’ y p [ n ] ’ )
xlabel ( ’n ’ )
657 AV = a x i s ;
a x i s ( [ 0 (Np − 1 ) 0 6 ] ) ;
659 %
661
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
663 % c o n v o l u c a o p e r i o d i c a de h com x e s p e l h a d o s e d e s l o c a d o s
% Np = 6
665 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
667 Fig I n d = F ig I nd + 1 ;
f i g u r e ( Fi g In d )
669
%
671 YlabelStrHpXpd = [ ’ h p [ k ] \ c d o t x p [−k ] ’ ; ’ h p [ k ] \ c d o t x p [−k+1] ’ ;
’ h p [ k ] \ c d o t x p [−k+2] ’ ; ’ h p [ k ] \ c d o t x p [−k+3] ’ ;
673 ’ h p [ k ] \ c d o t x p [−k+4] ’ ; ’ h p [ k ] \ c d o t x p [−k+5] ’
];
675 k = 0 : ( Np−1);
kind = k+1;
677
%
679 myhpxpd = [ ] ;
f o r i n d = 1 : Np
681 myhpxpd = [ myhpxpd ( hpk ( kind ) . * mxpd( kind , i n d ) ) ] ;
end
683 %
f o r SubInd = 0 : ( Np−1)
TET / UFF
110 Capı́tulo 3. Sinais no domı́nio do tempo
693 %
y = [];
695 f o r i n d = 1 : Np
y = [ y sum ( myhpxpd ( kind , i n d ) ) ] ;
697 end
%
699 s u b p l o t ( 2 , 4 , ( Np+2))
stem ( k , y )
701 t i t l e ( ’ Convolu ç ã o p e r i ó d i c a ( N p = 6 ) ’ )
ylabel ( ’y p [n] ’ )
703 x l a b e l ( ’ n ’ )
AV = a x i s ;
705 a x i s ( [ 0 (Np − 1 ) 0 6 ] ) ;
%
707
709 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% C o n s t a n t e s para c o n v o l u c a o p e r i o d i c a
711 % com numero i n s u f i c i e n t e de amostras
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
713 %
Nc = 4 ; % Nesse e x e r c i c i o , u s a r 2 < N < 8 .
715
717 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% c o n v o l u c a o c i r c u l a r de x com h c i r c u l a n t e
719 % Nc = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
721 %
Fig I n d = F ig I nd + 1 ;
723 f i g u r e ( Fig I n d )
725 %
i n d = 1 : Nc ;
727 n = ( ind −1);
729 %
xc = xn ( i n d ) ;
731 %
hc = hn ( i n d ) ;
733 c = hc ;
f o r i = 2 : Nc
735 hc = c i r c s h i f t ( hc , [ 1 0 ] ) ;
c = [ c hc ] ;
737 end
%
739 yc = c * xc ;
%
741 stem ( n , yc )
t i t l e ( ’ Convolu ç ã o c i r c u l a r com h [ n ] c i r c u l a n t e ( N c = 4 ) ’ )
743 y l a b e l ( ’ y c [ n ] ’ )
A.S.V.
3.3. Operações básicas sobre sequências 111
xlabel ( ’n ’ )
745 AV = a x i s ;
axis ([0 5 0 6 ] ) ;
747
749 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% c o n v o l u c a o c i r c u l a r de h com x c i r c u l a n t e
751 % Nc = 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
753 %
Fig I n d = F ig I nd + 1 ;
755 f i g u r e ( Fi g In d )
757 %
i n d = 1 : Nc ;
759 n = ( ind −1);
761 %
hc = hn ( i n d ) ;
763 %
xc = xn ( i n d ) ;
765 c = xc ;
f o r i = 2 : Nc
767 xc = c i r c s h i f t ( xc , [ 1 0 ] ) ;
c = [ c xc ] ;
769 end
%
771 yc = c * hc ;
%
773 stem ( n , yc )
t i t l e ( ’ Convolu ç ã o c i r c u l a r com x [ n ] c i r c u l a n t e ( N c = 4 ) ’ )
775 y l a b e l ( ’ y c [ n ] ’ )
xlabel ( ’n ’ )
777 AV = a x i s ;
axis ([0 5 0 6 ] ) ;
779
781 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% C o n s t a n t e s para c o n v o l u c a o p e r i o d i c a
783 % com numero s u f i c i e n t e de amostras
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
785 %
Nc = 6 ; % Nesse e x e r c i c i o , u s a r 2 < N < 8 .
787
789 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% c o n v o l u c a o c i r c u l a r de x com h c i r c u l a n t e
791 % Nc = 6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
793 %
Fig I n d = F ig I nd + 1 ;
795 f i g u r e ( Fi g In d )
797 %
i n d = 1 : Nc ;
799 n = ( ind −1);
801 %
xc = xn ( i n d ) ;
TET / UFF
112 Capı́tulo 3. Sinais no domı́nio do tempo
803 %
hc = hn ( i n d ) ;
805 c = hc ;
f o r i = 2 : Nc
807 hc = c i r c s h i f t ( hc , [ 1 0 ] ) ;
c = [ c hc ] ;
809 end
%
811 yc = c * xc ;
%
813 stem ( n , yc )
t i t l e ( ’ Convolu ç ã o c i r c u l a r com h [ n ] c i r c u l a n t e ( N c = 6 ) ’ )
815 y l a b e l ( ’ y c [ n ] ’ )
xlabel ( ’n ’ )
817 AV = a x i s ;
axis ([0 5 0 6 ] ) ;
819
821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% c o n v o l u c a o c i r c u l a r de h com x c i r c u l a n t e
823 % Nc = 6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
825 %
Fig I n d = F ig I nd + 1 ;
827 f i g u r e ( Fig I n d )
829 %
i n d = 1 : Nc ;
831 n = ( ind −1);
833 %
hc = hn ( i n d ) ;
835 %
xc = xn ( i n d ) ;
837 c = xc ;
f o r i = 2 : Nc
839 xc = c i r c s h i f t ( xc , [ 1 0 ] ) ;
c = [ c xc ] ;
841 end
%
843 yc = c * hc ;
%
845 stem ( n , yc )
t i t l e ( ’ Convolu ç ã o c i r c u l a r com x [ n ] c i r c u l a n t e ( N c = 6 ) ’ )
847 y l a b e l ( ’ y c [ n ] ’ )
xlabel ( ’n ’ )
849 AV = a x i s ;
axis ([0 5 0 6 ] ) ;
851
%
853 % EOF
%
A.S.V.
3.4. Sequências mais comumente empregadas 113
8 %
clear all
10 c l o s e a l l
12 menu choice = 1 ;
w h i l e ( menu choice ˜= 0 )
14 for i = 1:50
disp ( ’ ’ )
16 end
disp ( ’ ********************************* ’ )
18 disp ( ’ * Gera ç ã o de sequ ê n c i a s bá s i c a s * ’ )
disp ( ’ ********************************* ’ )
20 disp ( ’ ’ )
d i s p ( ’ Opç õ e s : ’ )
22 disp ( ’ 00 − S a i r ’ )
disp ( ’ 01 − Degrau u n i t á r i o ’ )
24 disp ( ’ 02 − D i r i c h l e t u n i t á r i a ’ )
disp ( ’ 03 − Gate r e t a n g u l a r u n i t á r i o ’ )
26 disp ( ’ 04 − Impulso u n i t á r i o ’ )
disp ( ’ 05 − Sequ ê n c i a l i n e a r u n i t á r i a ’ )
28 disp ( ’ 06 − Mó d u l o u n i t á r i o ’ )
disp ( ’ 07 − E x p o n e n c i a l u n i t á r i a ’ )
30 disp ( ’ 08 − Rampa u n i t á r i a ’ )
TET / UFF
114 Capı́tulo 3. Sinais no domı́nio do tempo
disp ( ’ 09 − Signum u n i t á r i o ’ )
32 disp ( ’ 10 − S i n c u n i t á r i a ’ )
disp ( ’ ’)
34 menu choice = i n p u t ( ’ E s c o l h a : ’ ) ;
disp ( ’ ’)
36
s w i t c h menu choice
38 c a s e {0}
disp ( ’ ’ )
40 d i s p ( ’ Bye . . . ’ )
disp ( ’ ’ )
42 c a s e {1}
d i s p ( ’ Degrau u n i t á r i o ’ )
44 t = i n p u t ( ’ Faixa de tempo no formato IN Í CIO : FIM =
’ );
stem ( t , d e g r a u u n i t a r i o ( t ) )
46 t i t l e ( ’ Degrau u n i t á r i o ’ )
ylabel ( ’u [ n ] ’ )
48 xlabel ( ’n ’ )
c a s e {2}
50 d i s p ( ’ D i r i c h l e t u n i t á r i a ’ )
N = i n p u t ( ’ Per ı́ odo = ’ ) ;
52 t = i n p u t ( ’ Faixa de tempo no formato IN Í CIO : FIM =
’ );
[ s , n ] = d r c l u n i t a r i a ( t ,N ) ;
54 stem ( t , s )
t i t l e ( ’ D i r i c h l e t u n i t á r i a ’ )
56 y l a b e l ( ’ Drcl [ n ] ’ )
xlabel ( ’n ’ )
58 c a s e {3}
d i s p ( ’ Gate r e t a n g u l a r u n i t á r i o ’ )
60 Ng = i n p u t ( ’ Número de a m o s tra s do g a t e = ’ ) ;
t = i n p u t ( ’ Faixa de tempo no formato i n i c i o : fim
= ’ );
62 stem ( t , g a t e r e t a n g u n i t a r i o (Ng , t ) )
t i t l e ( ’ Gate r e t a n g u l a r u n i t á r i o ’ )
64 y l a b e l ( ’ G {Ng} [ n ] ’ )
xlabel ( ’n ’ )
66 c a s e {4}
d i s p ( ’ Impulso u n i t á r i o ’ )
68 t = i n p u t ( ’ Faixa de tempo no formato IN Í CIO : FIM =
’ );
stem ( t , i m p u l s o u n i t a r i o ( t ) )
70 t i t l e ( ’ Impulso u n i t á r i o ’ )
ylabel ( ’\ delta [ n ] ’ )
72 xlabel ( ’n ’ )
c a s e {5}
74 d i s p ( ’ Sequ ê n c i a l i n e a r u n i t á r i a ’ )
t = i n p u t ( ’ Faixa de tempo no formato IN Í CIO : FIM =
’ );
76 stem ( t , l i n e a r u n i t a r i a ( t ) )
t i t l e ( ’ Sequ ê n c i a l i n e a r u n i t á r i a ’ )
78 y l a b e l ( ’ Lin [ n ] ’ )
xlabel ( ’n ’ )
80 c a s e {6}
d i s p ( ’ Mó d u l o u n i t á r i o ’ )
82 t = i n p u t ( ’ Faixa de tempo no formato IN Í CIO : FIM =
’ );
A.S.V.
3.4. Sequências mais comumente empregadas 115
stem ( t , m o d u l o u n i t a r i o ( t ) )
84 t i t l e ( ’Mó d u l o u n i t á r i o ’ )
y l a b e l ( ’Mod [ n ] ’ )
86 xlabel ( ’n ’ )
c a s e {7}
88 d i s p ( ’ E x p o n e n c i a l u n i t á r i a ’ )
b a s e = i n p u t ( ’ Base = ’ ) ;
90 t = i n p u t ( ’ Faixa de tempo no formato i n i c i o : fim
= ’ );
stem ( t , p o w e r u n i t a r i a ( base , t ) )
92 t i t l e ( ’ E x p o n e n c i a l u n i t á r i a ’ )
y l a b e l ( ’ Base ˆn ’ )
94 xlabel ( ’n ’ )
c a s e {8}
96 d i s p ( ’ Rampa u n i t á r i a ’ )
t = i n p u t ( ’ Faixa de tempo no formato IN Í CIO : FIM =
’ );
98 stem ( t , r a m p a u n i t a r i a ( t ) )
t i t l e ( ’Rampa u n i t á r i a ’ )
100 y l a b e l ( ’Rmp [ n ] ’ )
xlabel ( ’n ’ )
102 c a s e {9}
d i s p ( ’ Signum u n i t á r i o ’ )
104 t = i n p u t ( ’ Faixa de tempo no formato IN Í CIO : FIM =
’ );
stem ( t , s i g n u m u n i t a r i o ( t ) )
106 t i t l e ( ’ Signum u n i t á r i o ’ )
y l a b e l ( ’ Sgn [ n ] ’ )
108 xlabel ( ’n ’ )
c a s e {10}
110 d i s p ( ’ S i n c u n i t á r i a ’ )
t = i n p u t ( ’ Faixa de tempo no formato IN Í CIO : FIM =
’ );
112 [ s ,n] = sinc unitaria ( t );
stem ( t , s )
114 t i t l e ( ’ S i n c u n i t á r i a ’ )
ylabel ( ’ Sinc [ n ] ’ )
116 xlabel ( ’n ’ )
otherwise
118 % ’ do n o t h i n g . . . ’
end % s w i t c h
120 end % w h i l e
122
%
124 % EOF
%
TET / UFF
116 Capı́tulo 3. Sinais no domı́nio do tempo
9 %
% degrau unitario Gera f u n c a o Degrau U n i t a r i o D i g i t a l .
11 %
13 % g e r a s i n a l com i n d i c e s o r i g i n a i s
s t = 1 . * ( t >=0);
15
% d e s c o b r e i n d i c e s nao d i s c r e t o s de t
17 n o t d i s c i n d = f i n d ( round ( t ) ˜= t ) ;
19 % i n d i c a i n d i c e s que d e v e r a o s e r i g n o r a d o s
s t ( n o t d i s c i n d ) = NaN;
21
% r e t o r n a s i n a l com i n d i c e s i n t e i r o s
23 s = s t ;
25 %
% EOF
27 %
9 %
% drcl unitaria Gera fun ç ão D i r i c h l e t Unit á r i a .
11 %
% É e s p e r a d o : t = −Tmax . . . 0 . . . Tmax .
13 %
15 % d e s c o b r e i n d i c e t =0
i n d t 0 = f i n d ( t == 0 ) ;
17
% g e r a nova f a i x a de i n d i c e s
19 n = ( 1 : l e n g t h ( t ) ) − i n d t 0 ;
21 % g e r a s i n a l com i n d i c e s o r i g i n a i s
s = d i r i c ( 2 * p i * t ,N ) ;
23
%
25 % EOF
%
A.S.V.
3.4. Sequências mais comumente empregadas 117
4 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 %
f u n c t i o n s = g a t e r e t a n g u n i t a r i o (Ng , t )
8
%
10 % g a t e r e t a n g u n i t a r i o Gera f u n c a o Gate R e t a n g u l a r U n i t a r i o D i g i t a l .
%
12
% g e r a s i n a l com i n d i c e s o r i g i n a i s
14 s t = 1. * ( − abs (Ng)<=t & t<= abs (Ng ) ) ;
16 % d e s c o b r e i n d i c e s nao d i s c r e t o s de t
n o t d i s c i n d = f i n d ( round ( t ) ˜= t ) ;
18
% i n d i c a i n d i c e s que d e v e r a o s e r i g n o r a d o s
20 s t ( n o t d i s c i n d ) = NaN;
22 % r e t o r n a s i n a l com i n d i c e s i n t e i r o s
s = st ;
24
%
26 % EOF
%
9 %
% impulso unitario Gera f u n c a o Impulso U n i t a r i o D i g i t a l .
11 %
13 % g e r a s i n a l com i n d i c e s o r i g i n a i s
s t = 1 . * ( t ==0);
15
% d e s c o b r e i n d i c e s nao d i s c r e t o s de t
17 n o t d i s c i n d = f i n d ( round ( t ) ˜= t ) ;
19 % i n d i c a i n d i c e s que d e v e r a o s e r i g n o r a d o s
s t ( n o t d i s c i n d ) = NaN;
21
% r e t o r n a s i n a l com i n d i c e s i n t e i r o s
23 s = s t ;
25 %
% EOF
27 %
TET / UFF
118 Capı́tulo 3. Sinais no domı́nio do tempo
9 %
% linear unitaria Gera f u n c a o L i n e a r U n i t a r i a D i g i t a l .
11 %
13 % g e r a s i n a l com i n d i c e s o r i g i n a i s
st = t ;
15
% d e s c o b r e i n d i c e s nao d i s c r e t o s de t
17 n o t d i s c i n d = f i n d ( round ( t ) ˜= t ) ;
19 % i n d i c a i n d i c e s que d e v e r a o s e r i g n o r a d o s
s t ( n o t d i s c i n d ) = NaN;
21
% r e t o r n a s i n a l com i n d i c e s i n t e i r o s
23 s = s t ;
25 %
% EOF
27 %
9 %
% modulo unitario Gera f u n c a o Modulo U n i t a r i o D i g i t a l .
11 %
13 % g e r a s i n a l com i n d i c e s o r i g i n a i s
s t = −t . * ( t <0) + t . * (0<= t ) ;
15
% d e s c o b r e i n d i c e s nao d i s c r e t o s de t
17 n o t d i s c i n d = f i n d ( round ( t ) ˜= t ) ;
19 % i n d i c a i n d i c e s que d e v e r a o s e r i g n o r a d o s
s t ( n o t d i s c i n d ) = NaN;
21
% r e t o r n a s i n a l com i n d i c e s i n t e i r o s
23 s = s t ;
25 %
% EOF
A.S.V.
3.4. Sequências mais comumente empregadas 119
27 %
9 %
% power unitaria Gera f u n c a o P o t e n c i a c a o U n i t a r i a D i g i t a l .
11 %
13 % g e r a s i n a l com i n d i c e s o r i g i n a i s
s t = power ( base , t ) ;
15
% d e s c o b r e i n d i c e s nao d i s c r e t o s de t
17 n o t d i s c i n d = f i n d ( round ( t ) ˜= t ) ;
19 % i n d i c a i n d i c e s que d e v e r a o s e r i g n o r a d o s
s t ( n o t d i s c i n d ) = NaN;
21
% r e t o r n a s i n a l com i n d i c e s i n t e i r o s
23 s = s t ;
25 %
% EOF
27 %
9 %
% rampa unitaria Gera f u n c a o Rampa U n i t a r i a D i g i t a l .
11 %
13 % g e r a s i n a l com i n d i c e s o r i g i n a i s
s t = t . * ( t >=0);
15
% d e s c o b r e i n d i c e s nao d i s c r e t o s de t
17 n o t d i s c i n d = f i n d ( round ( t ) ˜= t ) ;
19 % i n d i c a i n d i c e s que d e v e r a o s e r i g n o r a d o s
s t ( n o t d i s c i n d ) = NaN;
21
TET / UFF
120 Capı́tulo 3. Sinais no domı́nio do tempo
% r e t o r n a s i n a l com i n d i c e s i n t e i r o s
23 s = st ;
25 %
% EOF
27 %
9 %
% signum unitario Gera f u n c a o Signum U n i t a r i o D i g i t a l .
11 %
13 % g e r a s i n a l com i n d i c e s o r i g i n a i s
s t = −1. * ( t <0) + 1. * (0 < t ) ;
15
% d e s c o b r e i n d i c e s nao d i s c r e t o s de t
17 n o t d i s c i n d = f i n d ( round ( t ) ˜= t ) ;
19 % i n d i c a i n d i c e s que d e v e r a o s e r i g n o r a d o s
s t ( n o t d i s c i n d ) = NaN;
21
% r e t o r n a s i n a l com i n d i c e s i n t e i r o s
23 s = s t ;
25 %
% EOF
27 %
9 %
% sinc unitaria Gera f u n c a o S i n c U n i t a r i a .
11 %
13 % d e s c o b r e i n d i c e t =0
i n d t 0 = f i n d ( t == 0 ) ;
15
% g e r a nova f a i x a de i n d i c e s
A.S.V.
3.4. Sequências mais comumente empregadas 121
17 n = ( 1 : length ( t )) − ind t 0 ;
19 % g e r a s i n a l com i n d i c e s o r i g i n a i s
s = sinc ( t );
21
%
23 % EOF
%
8
%
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
12 % T i t u l o : Demo de s e q u e n c i a e x p o n e n c i a l r e a l
%
14 % Autor : A l e x a n d r e S a n t o s de l a Vega
% Data : 30/03/2 k9 ; 08/09/2 k9
16 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18 %
20 % l i m p e z a do ambiente de t r a b a l h o
% variaveis
22 c l e a r a l l
% janelas
24 c l o s e a l l
26
% d e f i n i c a o dos p ar amet ro s
28 n = 0:10;
A = 1;
30 a l f a p o s 1 i n f = 2;
alfa pos 1 = 1;
32 a l f a p o s 0 1 = 0.2;
alfa neg 1 0 = − 0.2;
34 a l f a n e g 1 = − 1;
alfa neg inf 1 = − 2;
36
38 % g r a f i c o s
figure (1)
40 stem ( n , (A* p o w e r u n i t a r i a ( a l f a p o s 1 i n f , n ) ) )
t i t l e ( ’ e x p o n e n c i a l r e a l : \ a l p h a ˆn , \ a l p h a = ( 1 ; \ i n f t y ) ’ )
42 x l a b e l ( ’ n ’ )
44 figure (2)
stem ( n , (A* p o w e r u n i t a r i a ( a l f a p o s 1 , n ) ) )
46 t i t l e ( ’ e x p o n e n c i a l r e a l : \ a l p h a ˆn , \ a l p h a = 1 ’ )
TET / UFF
122 Capı́tulo 3. Sinais no domı́nio do tempo
xlabel ( ’n ’ )
48
figure (3)
50 stem ( n , (A* p o w e r u n i t a r i a ( a l f a p o s 0 1 , n ) ) )
t i t l e ( ’ e x p o n e n c i a l r e a l : \ a l p h a ˆn , \ a l p h a = ( 0 ; 1 ) ’ )
52 xlabel ( ’n ’ )
54 figure (4)
stem ( n , (A* p o w e r u n i t a r i a ( a l f a n e g 1 0 , n ) ) )
56 t i t l e ( ’ e x p o n e n c i a l r e a l : \ a l p h a ˆn , \ a l p h a = (−1 ; 0 ) ’ )
xlabel ( ’n ’ )
58
figure (5)
60 stem ( n , (A* p o w e r u n i t a r i a ( a l f a n e g 1 , n ) ) )
t i t l e ( ’ e x p o n e n c i a l r e a l : \ a l p h a ˆn , \ a l p h a = −1 ’ )
62 xlabel ( ’n ’ )
64 figure (6)
stem ( n , (A* p o w e r u n i t a r i a ( a l f a n e g i n f 1 , n ) ) )
66 t i t l e ( ’ e x p o n e n c i a l r e a l : \ a l p h a ˆn , \ a l p h a = (−\ i n f t y ; −1) ’ )
xlabel ( ’n ’ )
68
70 figure (7)
subplot (2 ,3 ,1)
72 stem ( n , (A* p o w e r u n i t a r i a ( a l f a p o s 1 i n f , n ) ) )
y l a b e l ( ’ \ alpha = (1 ; \ i n f t y ) ’ )
74 xlabel ( ’n ’ )
76 subplot (2 ,3 ,2)
stem ( n , (A* p o w e r u n i t a r i a ( a l f a p o s 1 , n ) ) )
78 y l a b e l ( ’ \ alpha = 1 ’ )
xlabel ( ’n ’ )
80
t i t l e ( ’ e x p o n e n c i a l r e a l : \ a l p h a ˆn ’ )
82
subplot (2 ,3 ,3)
84 stem ( n , (A* p o w e r u n i t a r i a ( a l f a p o s 0 1 , n ) ) )
y l a b e l ( ’ \ alpha = (0 ; 1) ’ )
86 xlabel ( ’n ’ )
88 subplot (2 ,3 ,6)
stem ( n , (A* p o w e r u n i t a r i a ( a l f a n e g 1 0 , n ) ) )
90 y l a b e l ( ’ \ a l p h a = (−1 ; 0 ) ’ )
xlabel ( ’n ’ )
92
subplot (2 ,3 ,5)
94 stem ( n , (A* p o w e r u n i t a r i a ( a l f a n e g 1 , n ) ) )
y l a b e l ( ’ \ a l p h a = −1 ’ )
96 xlabel ( ’n ’ )
98 subplot (2 ,3 ,4)
stem ( n , (A* p o w e r u n i t a r i a ( a l f a n e g i n f 1 , n ) ) )
100 y l a b e l ( ’ \ a l p h a = (−\ i n f t y ; −1) ’ )
xlabel ( ’n ’ )
102
104 %
% EOF
A.S.V.
3.4. Sequências mais comumente empregadas 123
106 %
TET / UFF
124 Capı́tulo 3. Sinais no domı́nio do tempo
A.S.V.
Capı́tulo 4
Sequências exponenciais
4.1 Introdução
Sequências exponenciais desempenham um papel fundamental em processamento de sinais.
Nas seções que se seguem, são apresentadas diversas listagens de programas, relativas a tal
assunto.
8
%
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
12 % T i t u l o : Demo de
% sequencia exponencial
14 % i n t e r p r e t a d a como f a s o r d i s c r e t o .
%
16 % − Exp ( ) como f a s o r .
% − Relacao de E u l e r :
18 % exp ( ) = c o s ( ) + j s i n ( ) .
% − Simulacao p a s s o a p a s s o .
20 % − V i s o e s 2D e 3D para exp ( ) .
% − Taxa de v a r i a c a o X Nf e Omega .
125
126 Capı́tulo 4. Sequências exponenciais
22 %
%
24 % Autor : A l e x a n d r e S a n t o s de l a Vega
% Data : / 2021−01 /
26 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 %
30 %
% −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
32 %
34 %
clear all
36 c l o s e a l l
38 %
% −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
40 %
42 %
% Definicoes gerais
44 %
46 %
mv opt = q u e s t d l g ( ”Temporizado ou Manual ? ” , . . .
48 ” C o n t r o l e do movimento de f a s o r d i s c r e t o ” , . . .
”Temporizado ” , ”Manual ( t e c l a d o ou mouse ) ” , ”Cancela ” , . . .
50 ”Temporizado ” ) ;
%
52 i f ( strcmp ( mv opt , ”Cancela ” ) )
%d i s p ( ”You c a n c e l l e d . ”) ;
54 return ;
endif
56 %
i f ( strcmp ( mv opt , ”Temporizado ” ) )
58 %
o p t i o n s c e l l = { ”0.0 ” , ”0.5 ” , ”1.0 ” , ”1.5 ” , ”2.0 ” , ”2.5 ” , ”3.0 ”};
60 [ s e l i n d , ok ] = l i s t d l g (
”Name” , ” I n t e r v a l o de tempo ( s ) ” ,
62 ” C a n c e l S t r i n g ” , ”Cancela ” ,
”ListSize ” , [180 ,130] ,
64 ”ListString ” , options cell ,
”S e l e c t i o n M o d e ” , ” S i n g l e ”
66 );
%
68 i f ( ok == 1 )
t p a u s e = str2num ( o p t i o n s c e l l { s e l i n d } ) ;
70 else
%d i s p ( ”You c a n c e l l e d . ”) ;
72 return ;
endif
74 %
endif
76
%
78 o p t i o n s c e l l = { ”32 ” , ”16 ” , ”8 ” , ”4 ” , ”3 ” } ;
[ s e l i n d , ok ] = l i s t d l g (
80 ”Name” , ”Per ı́ odo fundamental ( Nf ) ” ,
A.S.V.
4.2. Caracterı́sticas relevantes de exponenciais 127
” C a n c e l S t r i n g ” , ”Cancela ” ,
82 ”ListSize ” , [220 ,100] ,
”ListString ” , options cell ,
84 ”S e l e c t i o n M o d e ” , ” S i n g l e ”
);
86 %
i f ( ok == 1 )
88 Nf = str2num ( o p t i o n s c e l l { s e l i n d } ) ;
else
90 %d i s p ( ”You c a n c e l l e d . ”) ;
return ;
92 e n d i f
%
94 Omega Nf = ( 2 * p i /Nf ) ;
96 %
max Nf = 0 ;
98 f o r i n d =1: l e n g t h ( o p t i o n s c e l l )
N f i n d = str2num ( o p t i o n s c e l l { i n d } ) ;
100 i f ( N f i n d > max Nf )
max Nf = N f i n d ;
102 endif
endfor
104
%
106 % −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
%
108
%
110 % Construcao de
% Lugar Geometrico com r a i o c o n s t a n t e
112 % ou
% C i r c u l o de r a i o r
114 % ou
% |z| = r
116 % ou
% z = e ˆ( j Omega) ; −oo < Omega < oo
118 %
120 %
N = 360;
122 Omega step = 2 * p i /N;
Omega = 0 : Omega step : ( 2 * p i ) ;
124
%
126 c i r c 1 = e . ˆ ( j * Omega ) ;
re circ 1 = real ( circ 1 );
128 i m c i r c 1 = imag ( c i r c 1 ) ;
130 %
% −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−− −−−−−−−−−−
132 %
134 %
FigNbr = 0 ;
136 %
r lim = 1.3;
138 c l i m = ( ( 2 * max Nf ) −1);
%
TET / UFF
128 Capı́tulo 4. Sequências exponenciais
142 %
% −−−−−−−−−− −−−−−−−−−−
144 %
146 %
FigNbr = FigNbr + 1 ;
148 f i g u r e ( FigNbr )
%
150 f o r n = 0 : ( Nf −1)
%
152 f r 1 = e . ˆ ( j * Omega Nf * n ) ;
re f r1 = real ( f r1 );
154 i m f r 1 = imag ( f r 1 ) ;
156 %
subplot (2 ,2 ,1)
158 %
hold o f f
160 %
p l o t ( r e c i r c 1 , i m c i r c 1 , ”k ”)
162 %
h o l d on
164 %
p l o t ( r e f r 1 , i m f r 1 , ”ob ” , ” m a r k e r s i z e ” , 7 )
166 p l o t ( [ 0 , r e f r 1 ] , [ 0 , i m f r 1 ] , ”b ”)
%
168 p l o t ( r e f r 1 , 0 , ”o r ” , ” m a r k e r s i z e ” , 4 )
p l o t ( [ 0 , r e f r 1 ] , [ 0 , 0 ] , ”r ”)
170 %
p l o t ( 0 , i m f r 1 , ”og ” , ” m a r k e r s i z e ” , 4 )
172 p l o t ( [ 0 , 0 ] , [ i m f r 1 , 0 ] , ”g ”)
%
174 i f ( r e f r 1 > 0)
x txt = 1.1* r e f r 1 ;
176 y txt = 1.1* im f r1 ;
e l s e i f ( abs ( i m f r 1 ) < eps )
178 x txt = 0.9* r e f r 1 ;
y txt = 0 . 1 ;
180 else
x txt = 0.9* r e f r 1 ;
182 y txt = 1.1* im f r1 ;
end
184 t e x t ( x t x t , y t x t , [ ’ n = ’ , num2str ( n ) ] ) ;
%
186 a x i s ([ − r l i m , r l i m , −r l i m , r l i m ] )
% a x i s ( ” e q u a l ”) = s e t ( gca , ’ DataAspectRatio ’ , [ 1 , 1 , 1 ] )
188 a x i s ( ” e q u a l ”)
%
190 g r i d on
%
192 t i t s t r 1 = ’ Fasor d i s c r e t o : z [ n ] = e ˆ{ j ( \ Omega {0}n ) } ’ ;
t i t s t r 2 = [ ’ \Omega {0} = 2\ p i /N { f } = 2\ p i / ’ , . . .
194 num2str ( Nf ) , . . .
’ = ’ , num2str ( Omega Nf ) , ’ rad ’ ] ;
196 t i t l e ({ t i t s t r 1 , t i t s t r 2 } ) ;
y l a b e l ( ’ y [ n ] = Im \{ z [ n ] \ } = s i n ( \ Omega {0}n ) ’ )
198 x l a b e l ( ’ x [ n ] = Re \{ z [ n ] \ } = c o s ( \ Omega {0}n ) ’ )
A.S.V.
4.2. Caracterı́sticas relevantes de exponenciais 129
%
200
%
202 h sin = subplot (2 ,2 ,2);
%
204 h o l d on
%
206 stem ( n , i m f r 1 , ”og ”)
%
208 % a x i s ( [ 0 , ( Nf −1) , −r l i m , r l i m ] )
a x i s ( [ 0 , c l i m , −r l i m , r l i m ] )
210 a x i s ( ” s q u a r e ”)
%
212 g r i d on
%
214 t i t l e ( ’ y [ n ] = s i n ( \ Omega {0}n ) ’ ) ;
ylabel ( ’y [n] ’ )
216 xlabel ( ’n ’ )
%
218
%
220 h cos = subplot ( 2 , 2 , 3 ) ;
%
222 h o l d on
%
224 stem ( n , r e f r 1 , ”o r ”)
%
226 % a x i s ( [ 0 , ( Nf −1) , −r l i m , r l i m ] )
a x i s ( [ 0 , c l i m , −r l i m , r l i m ] )
228 a x i s ( ” s q u a r e ”)
%
230 g r i d on
%
232 t i t l e ( ’ x [ n ] = c o s ( \ Omega {0}n ) ’ ) ;
ylabel ( ’x [n] ’ )
234 xlabel ( ’n ’ )
%
236 %v i e w (AZIMUTH, ELEVATION)
view ( 9 0 , 9 0 )
238 %
240 %
subplot (2 ,2 ,4)
242 %
h o l d on
244 %
% stem3 ( x , y , z )
246 stem3 ( r e f r 1 , i m f r 1 , n , ”b ”)
%
248 a x i s ([ − r l i m , r l i m , −r l i m , r l i m , 0 , ( Nf − 1 ) ] )
a x i s ( ” s q u a r e ”)
250 %
g r i d on
252 %
t i t l e ( ’ Curva d i s c r e t a 3D: z [ n ] = e ˆ{ j ( \ Omega 0 n ) } ’ )
254 zlabel ( ’n ’ )
ylabel ( ’y [n] ’ )
256 xlabel ( ’x [n] ’ )
%
TET / UFF
130 Capı́tulo 4. Sequências exponenciais
294 %
n = 0: c lim ;
296 %
f r 1 = e . ˆ ( j * Omega Nf * n ) ;
298 %
re f r1 = real ( f r1 );
300 i m f r 1 = imag ( f r 1 ) ;
302 %
stem ( h s i n , n ( ( Nf +1): end ) , i m f r 1 ( ( Nf +1): end ) , ”ok ”)
304 stem ( h c o s , n ( ( Nf +1): end ) , r e f r 1 ( ( Nf +1): end ) , ”ok ”)
306 %
% EOF
308 %
A.S.V.
4.2. Caracterı́sticas relevantes de exponenciais 131
4 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6
8 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 %
% T i t u l o : Demo de
12 % sequencia exponencial
% i n t e r p r e t a d a como f a s o r
14 % ( v i s a o 3D)
%
16 % Autor : A l e x a n d r e S a n t o s de l a Vega
% Data : / 2010−02 / 2011−01 /
18 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 %
22
% l i m p e z a do ambiente de t r a b a l h o
24 % v a r i a v e i s
clear all
26 % j a n e l a s
close all
28
30 % d e f i n i c a o dos p ar amet ro s
NOD = 7 ; Theta0 = 0 ;
32 %NOD = 7 ; Theta0 = (2 * p i ) / ( (NOD+1) * 2);
%NOD = 1 5 ; Theta0 = 0 ;
34 %NOD = 1 5 ; Theta0 = (2 * p i ) / ( (NOD+1) * 2);
%
36 Omega0 = ( 2 * p i ) / (NOD+1);
38
% graficos
40 %
figure (1)
42 %
% cores
44 c e i x o = ’ k ’ ;
c disc = ’ r ’ ;
46 c c o n t = ’ b ’ ;
%
48 % e i x o
x = [0 0 ] ;
50 y = [ 0 0 ] ;
z = [ 0 NOD] ;
52 p l o t 3 ( z , x , y , c e i x o )
h o l d on
54 %
% fasor discreto
56 x = [ 0 0 ] ;
y = [0 0 ] ;
58 f o r n=0:NOD
x ( 2 ) = c o s ( Omega0 * n + Theta0 ) ;
60 y ( 2 ) = s i n ( Omega0 * n + Theta0 ) ;
z = [n n];
62 plot3 (z , x , y , c disc )
TET / UFF
132 Capı́tulo 4. Sequências exponenciais
end
64 %
% fasor continuo
66 n = ( 0 : 0 . 1 :NOD) ;
x = c o s ( Omega0 * n + Theta0 ) ;
68 y = s i n ( Omega0 * n + Theta0 ) ;
z = n;
70 p l o t 3 ( z , x , y , c c o n t )
%
72 t i t l e ( ’ Sequ ê n c i a e x p o n e n c i a l i n t e r p r e t a d a com f a s o r :
x [ n ] = e ˆ{ j ( \Omega n + \ Theta 0 ) } ’ )
74 y l a b e l ( ’ c o s ( \ Omega 0 n + \ Theta 0 ) ’ )
z l a b e l ( ’ s i n ( \ Omega 0 n + \ Theta 0 ) ’ )
76 x l a b e l ( ’ n ’ )
%
78 g r i d on
axis square
80 view ( 8 , 1 2 )
82
%
84 % EOF
%
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
11 % T i t u l o : Demo de s e q u e n c i a s e n o i d a l
%
13 % Autor : A l e x a n d r e S a n t o s de l a Vega
% Data : 30/03/2 k9 ; 03/09/2 k9
15 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 %
19 % l i m p e z a do ambien te de t r a b a l h o
% variaveis
21 c l e a r a l l
% janelas
23 c l o s e a l l
25
% d e f i n i c a o dos p ara met ro s
27 n = 0:50;
A = 1;
29 % 1o q u a d r a n t e
Omega11 = ( 0 ) ; % ( = 2 * p i ) (16 * Omega12 ) ( 8 * Omega12 ) ( 4 * Omega14 )
31 Omega12 = ( 2 * p i ) / 1 6 ;
A.S.V.
4.2. Caracterı́sticas relevantes de exponenciais 133
Omega13 = ( 2 * p i ) / 8 ; % ( 2 * Omega12 )
33 Omega14 = ( 2 * p i ) / 4 ; % ( 2 * Omega13 )
% 2o q u a d r a n t e
35 Omega21 = ( 2 * p i ) / 4 ;
Omega22 = ( 2 * p i ) / ( 8 / 3 ) ; % ( 3 * Omega13 )
37 Omega23 = ( 2 * p i ) / ( 1 6 / 7 ) ; % ( 7 * Omega12 )
Omega24 = ( 2 * p i ) / 2 ;
39 % 3o q u a d r a n t e
Omega31 = ( 2 * p i ) / 2 ;
41 Omega32 = ( 2 * p i ) / ( 1 6 / 9 ) ; % ( 9 * Omega12 )
Omega33 = ( 2 * p i ) / ( 8 / 5 ) ; % ( 5 * Omega13 )
43 Omega34 = ( 2 * p i ) / ( 4 / 3 ) ;
% 4o q u a d r a n t e
45 Omega41 = ( 2 * p i ) / ( 4 / 3 ) ;
Omega42 = ( 2 * p i ) / ( 8 / 7 ) ; % ( 7 * Omega13 )
47 Omega43 = ( 2 * p i ) / ( 1 6 / 1 5 ) ; % (15 * Omega12 )
Omega44 = ( 2 * p i ) ;
49
FigCntr = 0 ;
51
53 % g r a f i c o de a n g u l o s OmegaXY
k=1;
55 z = [ ] ;
p=[
57 c o s ( Omega11 ) + j * s i n ( Omega11 ) , c o s ( Omega11 ) − j * s i n ( Omega11 ) , ...
c o s ( Omega12 ) + j * s i n ( Omega12 ) , c o s ( Omega12 ) − j * s i n ( Omega12 ) , ...
59 c o s ( Omega13 ) + j * s i n ( Omega13 ) , c o s ( Omega13 ) − j * s i n ( Omega13 ) , ...
c o s ( Omega14 ) + j * s i n ( Omega14 ) , c o s ( Omega14 ) − j * s i n ( Omega14 ) , ...
61 c o s ( Omega21 ) + j * s i n ( Omega21 ) , c o s ( Omega21 ) − j * s i n ( Omega21 ) , ...
c o s ( Omega22 ) + j * s i n ( Omega22 ) , c o s ( Omega22 ) − j * s i n ( Omega22 ) , ...
63 c o s ( Omega23 ) + j * s i n ( Omega23 ) , c o s ( Omega23 ) − j * s i n ( Omega23 ) , ...
c o s ( Omega24 ) + j * s i n ( Omega24 ) , c o s ( Omega24 ) − j * s i n ( Omega24 ) , ...
65 c o s ( Omega31 ) + j * s i n ( Omega31 ) , c o s ( Omega31 ) − j * s i n ( Omega31 ) , ...
c o s ( Omega32 ) + j * s i n ( Omega32 ) , c o s ( Omega32 ) − j * s i n ( Omega32 ) , ...
67 c o s ( Omega33 ) + j * s i n ( Omega33 ) , c o s ( Omega33 ) − j * s i n ( Omega33 ) , ...
c o s ( Omega34 ) + j * s i n ( Omega34 ) , c o s ( Omega34 ) − j * s i n ( Omega34 ) , ...
69 c o s ( Omega41 ) + j * s i n ( Omega41 ) , c o s ( Omega41 ) − j * s i n ( Omega41 ) , ...
c o s ( Omega42 ) + j * s i n ( Omega42 ) , c o s ( Omega42 ) − j * s i n ( Omega42 ) , ...
71 c o s ( Omega43 ) + j * s i n ( Omega43 ) , c o s ( Omega43 ) − j * s i n ( Omega43 ) , ...
c o s ( Omega44 ) + j * s i n ( Omega44 ) , c o s ( Omega44 ) − j * s i n ( Omega44 ) , ...
73 ];
75 FigCntr = ( FigCntr + 1 ) ;
f i g u r e ( FigCntr )
77 pzmap ( zpk ( z , p , k ) )
t i t l e ( ’ Conjunto de â n g u l o s u t i l i z a d o s no exemplo ’ ) ;
79
81 % g r a f i c o s
83 % 1o q u a d r a n t e
FigCntr = ( FigCntr + 1 ) ;
85 f i g u r e ( FigCntr )
%
87 s u b p l o t ( 4 , 1 , 1 )
stem ( n , (A* c o s ( Omega11 * n ) ) )
89 %
h o l d on
TET / UFF
134 Capı́tulo 4. Sequências exponenciais
91 x = (0:2);
y = (A* c o s ( Omega11 * x ) ) ;
93 stem ( x , y , ’ y ’ )
hold o f f
95 %
y l a b e l ( ’ \Omega = 0 ’ )
97 t i t l e ( ’ S i n a l s e n o i d a l : A* c o s ( \Omega n ) , \Omega \ i n [ 0 , \ p i / 2 ] ’ )
99 subplot (4 ,1 ,2)
stem ( n , (A* c o s ( Omega12 * n ) ) )
101 %
h o l d on
103 na = 0 : . 1 : 5 0 ;
p l o t ( na , (A* c o s ( Omega12 * na ) ) , ’ k ’ )
105 hold o f f
%
107 h o l d on
x = (0:2:25);
109 y = (A* c o s ( Omega12 * x ) ) ;
stem ( x , y , ’ r ’ )
111 hold o f f
%
113 y l a b e l ( ’ \Omega = ( 2 * p i ) / 1 6 ’ )
A.S.V.
4.2. Caracterı́sticas relevantes de exponenciais 135
h o l d on
151 x = (0:4:8);
y = (A* c o s ( Omega14 * x ) ) ;
153 stem ( x , y , ’ y ’ )
hold o f f
155 %
y l a b e l ( ’ \Omega = ( 2 * p i ) / 4 ’ )
157
159 % 2o q u a d r a n t e
FigCntr = ( FigCntr + 1 ) ;
161 f i g u r e ( FigCntr )
%
163 s u b p l o t ( 4 , 1 , 1 )
stem ( n , (A* c o s ( Omega21 * n ) ) )
165 %
h o l d on
167 na = 0 : . 1 : 5 0 ;
p l o t ( na , (A* c o s ( Omega21 * na ) ) , ’ k ’ )
169 h o l d o f f
%
171 y l a b e l ( ’ \Omega = ( 2 * p i ) / 4 ’ )
t i t l e ( ’ S i n a l s e n o i d a l : A* c o s ( \Omega n ) , \Omega \ i n [ \ p i / 2 , \ p i ] ’ )
173
subplot (4 ,1 ,2)
175 stem ( n , (A* c o s ( Omega22 * n ) ) )
%
177 h o l d on
na = 0 : . 1 : 5 0 ;
179 p l o t ( na , (A* c o s ( Omega22 * na ) ) , ’ k ’ )
hold o f f
181 %
y l a b e l ( ’ \Omega = ( 2 * p i ) / ( 8 / 3 ) ’ )
183
subplot (4 ,1 ,3)
185 stem ( n , (A* c o s ( Omega23 * n ) ) )
%
187 h o l d on
na = 0 : . 1 : 5 0 ;
189 p l o t ( na , (A* c o s ( Omega23 * na ) ) , ’ k ’ )
hold o f f
191 %
y l a b e l ( ’ \Omega = ( 2 * p i ) / ( 1 6 / 7 ) ’ )
193
subplot (4 ,1 ,4)
195 stem ( n , (A* c o s ( Omega24 * n ) ) )
%
197 h o l d on
na = 0 : . 1 : 5 0 ;
199 p l o t ( na , (A* c o s ( Omega24 * na ) ) , ’ k ’ )
hold o f f
201 %
y l a b e l ( ’ \Omega = ( 2 * p i ) / 2 ’ )
203
205 % 3o q u a d r a n t e
FigCntr = ( FigCntr + 1 ) ;
207 f i g u r e ( FigCntr )
%
TET / UFF
136 Capı́tulo 4. Sequências exponenciais
231 % 4o q u a d r a n t e
FigCntr = ( FigCntr + 1 ) ;
233 f i g u r e ( FigCntr )
%
235 s u b p l o t ( 4 , 1 , 1 )
stem ( n , (A* c o s ( Omega41 * n ) ) )
237 %
y l a b e l ( ’ \Omega = ( 2 * p i ) / ( 4 / 3 ) ’ )
239 t i t l e ( ’ S i n a l s e n o i d a l : A* c o s ( \Omega n ) , \Omega \ i n [ 3 \ p i / 2 , 2 \ p i ] ’ )
257 % comparacoes
FigCntr = ( FigCntr + 1 ) ;
259 f i g u r e ( FigCntr )
%
261 s u b p l o t ( 4 , 1 , 1 )
stem ( n , (A* c o s ( Omega12 * n ) ) )
263 %
h o l d on
265 x = ( 0 : 7 : 5 0 ) ;
y = (A* c o s ( Omega12 * x ) ) ;
267 stem ( x , y , ’ r ’ )
A.S.V.
4.2. Caracterı́sticas relevantes de exponenciais 137
hold o f f
269 %
h o l d on
271 x = ( 0 : 9 : 5 0 ) ;
z = (A* c o s ( Omega12 * x ) ) ;
273 stem ( x , z , ’ g ’ )
hold o f f
275 %
h o l d on
277 x = ( 0 : 1 5 : 5 0 ) ;
w = (A* c o s ( Omega12 * x ) ) ;
279 stem ( x , w, ’ y ’ )
hold o f f
281 %
y l a b e l ( ’ \Omega = ( 2 * p i ) / 1 6 ’ )
283 t i t l e ( ’ S i n a l s e n o i d a l : A* c o s ( \Omega n ) ’ )
315
%
317 % EOF
%
TET / UFF
138 Capı́tulo 4. Sequências exponenciais
4 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6
8 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 %
% T i t u l o : Demo de
12 % p e r i o d i c i d a d e de c o s ( . )
%
14 % Autor : A l e x a n d r e S a n t o s de l a Vega
% Data : 30/03/2 k9 ; 03/09/2 k9
16 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18 %
20 % l i m p e z a do ambien te de t r a b a l h o
% variaveis
22 c l e a r a l l
% janelas
24 c l o s e a l l
26
% d e f i n i c a o dos p ara met ro s
28 ne = 0 : 1 0 0 0 ;
Femu = 5 0 0 ;
30 Temu = 1/Femu ;
32
n = 0:30;
34
Fs1 = 2 4 ;
36 Ts1 = 1/ Fs1 ;
38 Fs2 = 2 5 ;
Ts2 = 1/ Fs2 ;
40
Fs3 = 10 * s q r t ( 3 ) ;
42 Ts3 = 1/ Fs3 ;
44 f1 = 3;
f2 = 3;
46 f3 = 3;
48
% calculo das s e q u e n c i a s
50 x1a = c o s ( 2 * p i * f 1 * ( ne *Temu ) ) ;
x2a = c o s ( 2 * p i * f 2 * ( ne *Temu ) ) ;
52 x3a = c o s ( 2 * p i * f 3 * ( ne *Temu ) ) ;
54 x1 = c o s ( 2 * p i * f 1 * ( n * Ts1 ) ) ;
x2 = c o s ( 2 * p i * f 2 * ( n * Ts2 ) ) ;
56 x3 = c o s ( 2 * p i * f 3 * ( n * Ts3 ) ) ;
58
% graficos
60 %
% obtem tamanho de f u l l s c r e e n
62 s c r s z = g e t ( 0 , ’ S c r e e n S i z e ’ ) ; %[ l e f t , bottom , width , h e i g h t ]
A.S.V.
4.2. Caracterı́sticas relevantes de exponenciais 139
%
64 % t e n t a e v i t a r t o p b a r e bottom b a r
% a j u s t a t i p o de p a p e l
66 h1 = f i g u r e ( ’ PaperType ’ , ’ a4 ’ , . . .
’ Position ’ , [ scrsz (1) (0.07 * scrsz (4)) scrsz (3) (0.81 * scrsz ( 4 ) ) ] ) ;
68 %
% g r a f i c o s amostrados
70 s u b p l o t ( 3 , 2 , 2 )
stem ( n , x1 )
72 %
h o l d on
74 r = 0 : 8 ;
stem ( r , x1 ( r +1) , ’ r ’ )
76 h o l d o f f
%
78 t i t l e ( ’ S i n a l amostrado : c o s ( \Omega n ) = c o s ( 2 \ p i f n Ts ) ’ )
y l a b e l ( ’ \Omega 1 = 1/4 \ p i ; N 0 = 8 ’ )
80
subplot (3 ,2 ,4)
82 stem ( n , x2 )
%
84 h o l d on
r = 0:25;
86 stem ( r , x2 ( r +1) , ’ r ’ )
hold o f f
88 %
t i t l e ( ’ \Omega = ( \ omega Ts ) = ( 2 \ p i f Ts ) ’ )
90 y l a b e l ( ’ \Omega 2 = 6/25 \ p i ; N 0 = 25 ’ )
92 subplot (3 ,2 ,6)
stem ( n , x3 )
94 %
h o l d on
96 r = 0:30;
stem ( r , x3 ( r +1) , ’ r ’ )
98 hold o f f
%
100 t i t l e ( ’N f = K f * (F S / f 0 ) ’ )
y l a b e l ( ’ \Omega 3 = 6 / ( 1 0 s q r t ( 3 ) ) \ p i ; Nã o p e r i ó d i c o ! ’ )
102
x l a b e l ( ’ Amostra ( n ) ’ )
104
106 % g r a f i c o s a n a l o g i c o s
subplot (3 ,2 ,1)
108 p l o t ( ( ne *Temu ) , x1a )
%
110 h o l d on
x = ( 0 : 8 ) * Ts1 ;
112 y = x1 ( 1 : l e n g t h ( x ) ) ;
stem ( x , y , ’ r ’ )
114 h o l d o f f
%
116 y l a b e l ( ’ F { S 1 } = 24 Hz ’ )
t i t l e ( ’ S i n a l a n a l ó g i c o : c o s ( 2 \ p i f t ) ; f 0 = 3 Hz ’ )
118 g r i d on
TET / UFF
140 Capı́tulo 4. Sequências exponenciais
122 %
h o l d on
124 x = ( 0 : 2 5 ) * Ts2 ;
y = x2 ( 1 : l e n g t h ( x ) ) ;
126 stem ( x , y , ’ r ’ )
hold o f f
128 %
y l a b e l ( ’ F { S 2 } = 25 Hz ’ )
130 g r i d on
144 g r i d on
146
%
148 % EOF
%
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % Demos para %
% A p o s t i l a de DSP %
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 141
13 % %
% Topico : p r o c e s s o de amostragem %
15 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
17 % Modifs : /2010−01/2011−02/ %
% %
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
21
23 % lim p a ambiente
clear all
25 c l o s e a l l
27
% d e f i n e p ara met ro s
29 A0 = 1 ;
F0 = 1 e3 ;
31 T0 = 1/F0 ;
%
33 NOP = 2 ; % numero de p e r i o d o s v i s u a l i z a d o s
%
35 PPPa = 1 0 0 0 ; % numero de p o n t o s por p e r i o d o para s i n a l a n a l o g i c o
Tsa = T0/PPPa ;
37 t = 0 : Tsa : (NOP* T0 ) ;
%
39 PPPs = 1 0 ; % numero de p o n t o s por p e r i o d o para s i n a l amostrado
Tss = T0/PPPs ;
41 nTs = 0 : Tss : (NOP* T0 ) ;
%
43 n = 0 : ( l e n g t h ( nTs ) − 1 ) ;
45
% constroi sinais
47 xa = A0 * c o s ( 2 * p i * F0 * t ) ; % sinal analogico
xs = A0 * c o s ( 2 * p i * F0 * nTs ) ; % s i n a l amostrado
49
51 % q u a n t i z a s i n a i s usando f u n c a o d e f i n i d a e x t e r n a m e n t e
NOI = 5 ; % numero de i n t e r v a l o s do g r i d
53 %xaq = q u a n t h a l f g r i d ( xa ,−A0 , ( A0/NOI) , A0 ) ; % s i n a l a n a l o g i c o q u a n t i z a d o
xsq = q u a n t h a l f g r i d ( xs ,−A0 , ( A0/NOI ) , A0 ) ; % s i n a l amostrado q u a n t i z a d o
55
57 % desenha g r a f i c o s
figure (1)
59 %
subplot (3 ,2 ,1)
61 p l o t ( t , xa )
ylabel ( ’x( t ) ’ )
63 x l a b e l ( ’ t ( s ) ’ )
t i t l e ( ’ S i n a l a n a l ó g i c o : x ( t ) ’ )
65 %
subplot (3 ,2 ,3)
67 f o r k = 1 : l e n g t h ( nTs )
i f ( xs ( k ) == 0 )
69 stem ( nTs ( k ) , xs ( k ) , ’ k ’ )
e l s e i f ( xs ( k ) > 0 )
71 stem ( nTs ( k ) , xs ( k ) , ’ k ’ , ’ ˆ ’ )
TET / UFF
142 Capı́tulo 4. Sequências exponenciais
else
73 stem ( nTs ( k ) , xs ( k ) , ’ k ’ , ’ v ’ )
end
75 h o l d on
end
77 y l a b e l ( ’ x ( t ) * \ d e l t a {T S } ( t ) ’ )
xlabel ( ’ t ( s ) ’ )
79 t i t l e ( ’ S i n a l m u l t i p l i c a d o p e l o trem de i m p u l s o s : x ( t ) * \ d e l t a {T S } ( t ) ’ )
%
81 subplot (3 ,2 ,4)
stem ( nTs , xs )
83 ylabel ( ’x [n T s ] ’ )
xlabel ( ’ t ( s ) ’ )
85 t i t l e ( ’ S i n a l amostrado : x [ n T s ] = x ( t ) , para t = n T s ’ )
%
87 subplot (3 ,2 ,2)
stem ( nTs , ones ( 1 , l e n g t h ( nTs ) ) , ’ k ’ , ’ ˆ ’ )
89 y l a b e l ( ’ \ d e l t a {T S } ( t ) ’ )
xlabel ( ’ t ( s ) ’ )
91 t i t l e ( ’ Trem de i m p u l s o s : \ d e l t a {T S } ( t ) ’ )
%
93 subplot (3 ,2 ,5)
%stem ( nTs , [ x s ; x s q ] ’ ) % ’ f u n c i o n a , mas as c o r e s nao fi ca m ok ! . . . ’
95 stem ( nTs , xs , ’ bo− ’ )
h o l d on
97 stem ( nTs , xsq , ’ ro− ’ )
ylabel ( ’ [ x [n T S ] ] Q ’ )
99 xlabel ( ’ t ( s ) ’ )
t i t l e ( ’ S i n a l d i g i t a l : [ x [ n T S ] ] Q = [ x ( t ) ] Q , para t = n T S ’ )
101 %
subplot (3 ,2 ,6)
103 %stem ( n , [ x s ; x s q ] ’ ) % ’ f u n c i o n a , mas as c o r e s nao f ic a m ok ! . . . ’
stem ( n , xs , ’ bo− ’ )
105 h o l d on
stem ( n , xsq , ’ ro− ’ )
107 ylabel ( ’ [ x [n] ] Q ’ )
xlabel ( ’n ’ )
109 t i t l e ( ’ Sequ ê n c i a d i g i t a l : [ x [ n ] ] Q = [ x [ n T S ] ] Q ’ )
111
%
113 % EOF
%
8 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 %
% T i t u l o : Demo de
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 143
12 % s u p e r p o s i c a o de e s p e c t r o
% c o s ( p i * n + Theta0 ) = c o s ( p i * n )
14 %
% Autor : A l e x a n d r e S a n t o s de l a Vega
16 % Data : / 2010−02 / 2011−01 /
%
18 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
20
% l i m p e z a do ambiente de t r a b a l h o
22 % v a r i a v e i s
clear all
24 % j a n e l a s
close all
26
28 % d e f i n i c a o dos p ar amet ro s
ne = 0 : 5 0 0 ;
30 Femu = 5 0 0 ;
Temu = 1/Femu ;
32
n = 0:15;
34 %
F0 = 3 ;
36 Theta0 = ( 2 * p i ) / 8 ;
%
38 Fs = 2 * F0 ;
Ts = 1/ Fs ;
40
% c a l c u l o das s e q u e n c i a s
42 x1a = c o s ( ( 2 * p i * F0 * ( ne *Temu ) ) + Theta0 ) ;
x2a = c o s ( ( 2 * p i * F0 * ( ne *Temu ) ) ) * c o s ( Theta0 ) ;
44
x1 = c o s ( ( 2 * p i * F0 * ( n * Ts ) ) + Theta0 ) ;
46 x2 = c o s ( ( 2 * p i * F0 * ( n * Ts ) ) ) * c o s ( Theta0 ) ;
48
% graficos
50 %
figure (1)
52 s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
%
54 NORS = 6 ;
r = 0 :NORS;
56 %
% g r a f i c o s amostrados
58 s u b p l o t ( 2 , 2 , 2 )
stem ( n , x1 )
60 %
h o l d on
62 stem ( r , x1 ( r +1) , ’ r ’ )
hold o f f
64 %
t i t l e ( ’ S i n a i s amostrados : x 1 [ n ] = x 2 [ n ] ’ )
66 y l a b e l ( ’ x 1 [ n ] = c o s ( \ p i n + \ Theta 0 ) ’ )
AV = a x i s ;
68 a x i s ( [AV( 1 ) AV( 2 ) ( −1) ( 1 ) ] )
70 subplot (2 ,2 ,4)
TET / UFF
144 Capı́tulo 4. Sequências exponenciais
stem ( n , x2 )
72 %
h o l d on
74 stem ( r , x2 ( r +1) , ’ r ’ )
hold o f f
76 %
t i t l e ( ’ \Omega = ( \ omega Ts ) = ( 2 \ p i f Ts ) = \ p i rad ’ )
78 y l a b e l ( ’ x 2 [ n ] = c o s ( \ p i n ) * c o s ( \ Theta 0 ) ’ )
x l a b e l ( ’ Amostra ( n ) ’ )
80 AV = a x i s ;
a x i s ( [AV( 1 ) AV( 2 ) ( −1) ( 1 ) ] )
82
84 % g r a f i c o s a n a l o g i c o s
%
86 x = ( r ) * Ts ;
%
88 s u b p l o t ( 2 , 2 , 1 )
p l o t ( ( ne *Temu ) , x1a )
90 %
h o l d on
92 y = x1 ( 1 : l e n g t h ( x ) ) ;
stem ( x , y , ’ r ’ )
94 h o l d o f f
%
96 t i t l e ( ’ S i n a i s a n a l ó g i c o s : x 1 ( t ) \ neq x 2 ( t ) ’ )
y l a b e l ( ’ x 1 ( t ) = c o s ( 2 \ p i f 0 t + \ Theta 0 ) ’ )
98 %
g r i d on
100
subplot (2 ,2 ,3)
102 p l o t ( ( ne *Temu ) , x2a )
%
104 h o l d on
y = x2 ( 1 : l e n g t h ( x ) ) ;
106 stem ( x , y , ’ r ’ )
hold o f f
108 %
t i t l e ( ’ f 0 = 3 Hz ; F S = ( 2 f 0 ) Hz ; \ Theta 0 = ( 2 \ p i ) / 8 rad ’ )
110 y l a b e l ( ’ x 2 ( t ) = c o s ( 2 \ p i f 0 t ) * c o s ( \ Theta 0 ) ’ )
x l a b e l ( ’Tempo ( s ) ’ )
112 AV = a x i s ;
a x i s ( [AV( 1 ) AV( 2 ) ( −1) ( 1 ) ] )
114 %
g r i d on
116
%
118
figure (2)
120 s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
%
122 x = ( r ) * Ts ;
%
124 y = x1 ( 1 : l e n g t h ( x ) ) ;
stem ( x , y , ’ r ’ )
126 h o l d on
p l o t ( ( ne *Temu ) , x1a , ’ k ’ )
128 p l o t ( ( ne *Temu ) , x2a , ’ b ’ )
%
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 145
130 t i t s t r 1 = [ ’ S i n a i s a n a l ó g i c o s : ’ , ...
’ x 1 ( t ) = c o s ( 2 \ p i f 0 t + \ Theta 0 ) ’ , . . .
132 ’ \ neq c o s ( 2 \ p i f 0 t ) * c o s ( \ Theta 0 ) = x 2 ( t ) ’ ] ;
t i t s t r 2 = [ ’ f 0 = 3 Hz ; ’ , ...
134 ’ F S = ( 2 f 0 ) Hz ; ’ , ...
’ \ Theta 0 = ( 2 \ p i ) / 8 rad ; ’ , ...
136 ’ \Omega = \ p i rad ’ ] ;
t i t s t r 3 = [ ’ S i n a i s amostrados : ’ , ...
138 ’ x 1 [ n ] = c o s ( \ p i n + \ Theta 0 ) ’ , . . .
’= c o s ( \ p i n ) * c o s ( \ Theta 0 ) = x 2 [ n ] ’ ] ;
140 t i t l e ({ t i t s t r 1 , t i t s t r 2 , t i t s t r 3 })
y l a b e l ( ’ x 1 ( t ) \ neq x ( 2 ( t ) ; x 1 [ n ] = x 2 [ n ] ’ )
142 x l a b e l ( ’Tempo ( s ) ’ )
%
144 %g r i d on
146
%
148 % EOF
%
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
11 % T i t u l o : Demo de s u p e r p o s i c a o de e s p e c t r o
%
13 % Autor : A l e x a n d r e S a n t o s de l a Vega
% Data : 30/03/2 k9 ; 03/09/2 k9
15 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 %
19 % l i m p e z a do ambiente de t r a b a l h o
% variaveis
21 c l e a r a l l
% janelas
23 c l o s e a l l
25
% d e f i n i c a o dos p ar amet ro s
27 ne = 0 : 4 0 0 ;
%
29 Femu = 5 0 0 ;
Temu = 1/Femu ;
31
n = 0:20;
33 %
f1 = 3;
TET / UFF
146 Capı́tulo 4. Sequências exponenciais
35 f2 = 7;
f3 = 13;
37 %
Fs = 10;
39 Ts = 1/ Fs ;
41
% calculo das s e q u e n c i a s
43 x1a = c o s ( 2 * p i * f 1 * ( ne *Temu ) ) ;
x2a = c o s ( 2 * p i * f 2 * ( ne *Temu ) ) ;
45 x3a = c o s ( 2 * p i * f 3 * ( ne *Temu ) ) ;
47 x1 = c o s ( 2 * p i * f 1 * ( n * Ts ) ) ;
x2 = c o s ( 2 * p i * f 2 * ( n * Ts ) ) ;
49 x3 = c o s ( 2 * p i * f 3 * ( n * Ts ) ) ;
51
% graficos
53 %
figure (1)
55 s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
%
57 NORS = 5 ;
r = 0 :NORS;
59 %
% g r a f i c o s amostrados
61 s u b p l o t ( 3 , 2 , 2 )
stem ( n , x1 )
63 h o l d on
stem ( r , x1 ( r +1) , ’ r ’ )
65 h o l d o f f
%
67 y l a b e l ( ’ \Omega 1 = ( 0 . 6 \ p i ) rad ’ )
t i t l e ( ’ S i n a l amostrado : c o s ( \Omega n ) = c o s ( 2 \ p i f n Ts ) ’ )
69
subplot (3 ,2 ,4)
71 stem ( n , x2 )
%
73 h o l d on
stem ( r , x2 ( r +1) , ’ r ’ )
75 h o l d o f f
%
77 y l a b e l ( ’ \Omega 2 = ( 2 \ p i ) − ( 0 . 6 \ p i ) rad ’ )
t i t l e ( ’ \Omega = ( \ omega Ts ) = ( 2 \ p i f Ts ) ’ )
79
subplot (3 ,2 ,6)
81 stem ( n , x3 )
%
83 h o l d on
stem ( r , x3 ( r +1) , ’ r ’ )
85 h o l d o f f
%
87 y l a b e l ( ’ \Omega 3 = ( 2 \ p i ) + ( 0 . 6 \ p i ) rad ’ )
t i t l e ( ’ F S = 10 Hz ’ )
89
x l a b e l ( ’ Amostra ( n ) ’ )
91
93 % g r a f i c o s a n a l o g i c o s
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 147
x = ( r ) * Ts ;
95 %
subplot (3 ,2 ,1)
97 p l o t ( ( ne *Temu ) , x1a )
%
99 h o l d on
y = x1 ( 1 : l e n g t h ( x ) ) ;
101 stem ( x , y , ’ r ’ )
hold o f f
103 %
y l a b e l ( ’ f 1 = 3 Hz ’ )
105 t i t l e ( ’ S i n a l a n a l ó g i c o : c o s ( 2 \ p i f t ) ’ )
g r i d on
107
subplot (3 ,2 ,3)
109 p l o t ( ( ne *Temu ) , x2a )
%
111 h o l d on
x = ( 0 : 5 ) * Ts ;
113 y = x2 ( 1 : l e n g t h ( x ) ) ;
stem ( x , y , ’ r ’ )
115 h o l d o f f
%
117 y l a b e l ( ’ f 2 = 7 Hz ’ )
g r i d on
119
subplot (3 ,2 ,5)
121 p l o t ( ( ne *Temu ) , x3a )
%
123 h o l d on
x = ( 0 : 5 ) * Ts ;
125 y = x3 ( 1 : l e n g t h ( x ) ) ;
stem ( x , y , ’ r ’ )
127 h o l d o f f
%
129 y l a b e l ( ’ f 3 = 13 Hz ’ )
x l a b e l ( ’Tempo ( s ) ’ )
131 %
g r i d on
133
%
135
figure (2)
137 s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
%
139 x = ( r ) * Ts ;
%
141 y = x1 ( 1 : l e n g t h ( x ) ) ;
stem ( x , y , ’ r ’ )
143 h o l d on
p l o t ( ( ne *Temu ) , x1a , ’ : r ’ )
145 p l o t ( ( ne *Temu ) , x2a , ’ −.b ’ )
p l o t ( ( ne *Temu ) , x3a , ’ k ’ )
147 %
t i t l e ( { ’ S i n a l a n a l ó g i c o : c o s ( 2 \ p i f t ) ’ , . . .
149 ’ S i n a l amostrado : c o s ( \Omega n ) = c o s ( 2 \ p i f n Ts ) ’ } )
y l a b e l ( ’ f 1 = 3 Hz ; f 2 = 7 Hz ; f 3 = 13 Hz ; F S = 10 Hz ’ )
151 x l a b e l ( ’Tempo ( s ) ’ )
%
TET / UFF
148 Capı́tulo 4. Sequências exponenciais
153 %g r i d on
155 %
% EOF
157 %
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
11 % T i t u l o : Demo de s u p e r p o s i c a o de e s p e c t r o
%
13 % Autor : A l e x a n d r e S a n t o s de l a Vega
% Data : 30/03/2 k9 ; 03/09/2 k9
15 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 %
19 % l i m p e z a do ambien te de t r a b a l h o
% variaveis
21 c l e a r a l l
% janelas
23 c l o s e a l l
25
% d e f i n i c a o dos p ara met ro s
27 ne = 0 : 4 0 0 ;
%
29 Femu = 5 0 0 ;
Temu = 1/Femu ;
31
33 n = 0:20;
35 Fs1 = 1 0 0 ;
Ts1 = 1/ Fs1 ;
37
Fs2 = 1 0 ;
39 Ts2 = 1/ Fs2 ;
41 Fs3 = 3 / 0 . 7 ;
Ts3 = 1/ Fs3 ;
43
f1 = 3;
45 f2 = 3;
f3 = 3;
47
49 % c a l c u l o das s e q u e n c i a s
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 149
x1a = c o s ( 2 * p i * f 1 * ( ne *Temu ) ) ;
51 x2a = c o s ( 2 * p i * f 2 * ( ne *Temu ) ) ;
x3a = c o s ( 2 * p i * f 3 * ( ne *Temu ) ) ;
53
x1 = c o s ( 2 * p i * f 1 * ( n * Ts1 ) ) ;
55 x2 = c o s ( 2 * p i * f 2 * ( n * Ts2 ) ) ;
x3 = c o s ( 2 * p i * f 3 * ( n * Ts3 ) ) ;
57
59 % g r a f i c o s
61 figure (1)
s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
63 %
%
65 % g r a f i c o s amostrados
subplot (3 ,2 ,2)
67 stem ( n , x1 )
%
69 h o l d on
r = 0:11;
71 stem ( r , x1 ( r +1) , ’ r ’ )
hold o f f
73 %
y l a b e l ( ’ \Omega 1 = ( 0 . 0 6 \ p i ) rad ’ )
75 t i t l e ( ’ S i n a l amostrado : c o s ( \Omega n ) = c o s ( 2 \ p i f n Ts ) ’ )
77 subplot (3 ,2 ,4)
stem ( n , x2 )
79 %
h o l d on
81 r = 0:7;
stem ( r , x2 ( r +1) , ’ r ’ )
83 hold o f f
%
85 y l a b e l ( ’ \Omega 2 = ( 0 . 6 \ p i ) rad ’ )
t i t l e ( ’ \Omega = ( \ omega Ts ) = ( 2 \ p i f Ts ) ’ )
87
subplot (3 ,2 ,6)
89 stem ( n , x3 )
%
91 h o l d on
r = 0:3;
93 stem ( r , x3 ( r +1) , ’ r ’ )
hold o f f
95 %
y l a b e l ( ’ \Omega 3 = 1 . 4 \ p i = ( 2 \ p i ) − ( 0 . 6 \ p i ) rad ’ )
97 x l a b e l ( ’ Amostra ( n ) ’ )
%
99 %
% graficos analogicos
101 subplot (3 ,2 ,1)
p l o t ( ( ne *Temu ) , x1a )
103 %
h o l d on
105 x = ( 0 : 1 1 ) * Ts1 ;
y = x1 ( 1 : l e n g t h ( x ) ) ;
107 stem ( x , y , ’ r ’ )
hold o f f
TET / UFF
150 Capı́tulo 4. Sequências exponenciais
109 %
y l a b e l ( ’ F { S 1 } = 100 Hz ’ )
111 t i t l e ( ’ S i n a l a n a l ó g i c o : c o s ( 2 \ p i f t ) ; f 0 = 3 Hz ’ )
g r i d on
113
subplot (3 ,2 ,3)
115 p l o t ( ( ne *Temu ) , x2a )
%
117 h o l d on
x = ( 0 : 7 ) * Ts2 ;
119 y = x2 ( 1 : l e n g t h ( x ) ) ;
stem ( x , y , ’ r ’ )
121 h o l d o f f
%
123 y l a b e l ( ’ F { S 2 } = 10 Hz ’ )
g r i d on
125
subplot (3 ,2 ,5)
127 p l o t ( ( ne *Temu ) , x3a )
%
129 h o l d on
x = ( 0 : 3 ) * Ts3 ;
131 y = x3 ( 1 : l e n g t h ( x ) ) ;
stem ( x , y , ’ r ’ )
133 h o l d o f f
%
135 y l a b e l ( ’ F { S 3 } = ( 3 / 0 . 7 ) Hz ’ )
x l a b e l ( ’Tempo ( s ) ’ )
137 %
g r i d on
139
%
141 % EOF
%
8 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % %
% Titulo : %
12 % Demonstra ç ão de a l i a s i n g , i n t e r a g i n d o com o usu á r i o . %
% %
14 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Data : 01/09/2 k8 %
16 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18 %
20
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 151
%
22 clear all
close all
24
%
26 F1 = 2 5 0 ;
F2 = 1 2 5 0 ;
28 F3 = 2 2 5 0 ;
30
%
32 Tmin = 1/F3 ;
Tmax = 1/F1 ;
34
%
36 NbrPtsPer = 1 0 0 ;
38 %
TStepAna = Tmin/ NbrPtsPer ;
40 t a = 0 : TStepAna : 2 * Tmax ;
42 %
xa1 = c o s ( 2 * p i * F1 * t a ) ;
44 xa2 = c o s ( 2 * p i * F2 * t a ) ;
xa3 = c o s ( 2 * p i * F3 * t a ) ;
46
48 %
disp ( ’ ’ )
50 d i s p ( [ ’ Componentes do s i n a l com : ’ , ...
’ f 1 = 250 Hz , f 2 = 1250 Hz e f 3 = 2250 Hz . ’ ] )
52 d i s p ( ’ ’ )
Fs = i n p u t ( ’ Frequ ê n c i a de amostragem ( Hz ) : ’ );
54 Ts = 1/ Fs ;
nTs = 0 : Ts : 2 * Tmax ;
56
%
58 xd1 = c o s ( 2 * p i * F1 * nTs ) ;
xd2 = c o s ( 2 * p i * F2 * nTs ) ;
60 xd3 = c o s ( 2 * p i * F3 * nTs ) ;
62
%
64 FigCntr = 0 ;
n =0:( l e n g t h ( nTs ) −1);
66
%
68 FigCntr = ( FigCntr + 1 ) ;
f i g u r e ( FigCntr )
70 s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
72 subplot (3 ,2 ,1)
p l o t ( ta , xa1 )
74 y l a b e l ( ’ f 1 = 250 Hz ’ )
t i t l e ( ’ x ( t ) = cos (2 \ pi f t ) ’ )
76 subplot (3 ,2 ,3)
p l o t ( ta , xa2 )
78 y l a b e l ( ’ f 2 = 1250 Hz ’ )
subplot (3 ,2 ,5)
TET / UFF
152 Capı́tulo 4. Sequências exponenciais
80 p l o t ( ta , xa3 )
y l a b e l ( ’ f 3 = 2250 Hz ’ )
82 xlabel ( ’ t ( s ) ’ )
84 subplot (3 ,2 ,2)
stem ( nTs , xd1 )
86 t i t l e ( ’ x [ n T s ] = cos (2 \ pi f n T s ) ’ )
subplot (3 ,2 ,4)
88 stem ( nTs , xd2 )
subplot (3 ,2 ,6)
90 stem ( nTs , xd3 )
xlabel ( ’n T s ( s ) ’ )
92
94 %
FigCntr = ( FigCntr + 1 ) ;
96 f i g u r e ( FigCntr )
s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
98
subplot (3 ,2 ,1)
100 stem ( nTs , xd1 )
t i t l e ( ’ x [ n T s ] = cos (2 \ pi f n T s ) ’ )
102 s u b p l o t ( 3 , 2 , 3 )
stem ( nTs , xd2 )
104 s u b p l o t ( 3 , 2 , 5 )
stem ( nTs , xd3 )
106 x l a b e l ( ’ n T s ( s ) ’ )
118 %
FigCntr = ( FigCntr + 1 ) ;
120 f i g u r e ( FigCntr )
s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
122
subplot (3 ,2 ,1)
124 p l o t ( ta , xa1 )
y l a b e l ( ’ f 1 = 250 Hz ’ )
126 t i t l e ( ’ x ( t ) = c o s ( 2 \ p i f t ) ’ )
subplot (3 ,2 ,3)
128 p l o t ( ta , xa2 )
y l a b e l ( ’ f 2 = 1250 Hz ’ )
130 s u b p l o t ( 3 , 2 , 5 )
p l o t ( ta , xa3 )
132 y l a b e l ( ’ f 3 = 2250 Hz ’ )
xlabel ( ’ t ( s ) ’ )
134
subplot (3 ,2 ,2)
136 stem ( n , xd1 )
t i t l e ( ’ x [ n ] = c o s ( \Omega n ) ; \Omega = ( 2 \ p i f T s ) ’ )
138 s u b p l o t ( 3 , 2 , 4 )
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 153
stem ( n , xd2 )
140 subplot (3 ,2 ,6)
stem ( n , xd3 )
142 xlabel ( ’n ’ )
144
%
146 FigCntr = ( FigCntr + 1 ) ;
f i g u r e ( FigCntr )
148 s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
182 %
% EOF
184 %
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TET / UFF
154 Capı́tulo 4. Sequências exponenciais
% %
10 % Tı́ t u l o : %
% Demonstra ç ão de c a d e i a de p r o c e s s a m e n t o com a l i a s i n g %
12 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 % %
% Disciplina : %
16 % Processamento D i g i t a l de S i n a i s . %
% Professor : %
18 % A l e x a n d r e S a n t o s de l a Vega . %
% Per ı́ odo : %
20 % 2018 −1. %
% %
22 % A t i v i d a d e : %
% T e s t e S u r p r e s a 1 − 2018 1 − G a b a r i t o . %
24 % %
% Assunto : %
26 % Cadeia de p r o c e s s a m e n t o com amostragem inadequada , %
% causando a l i a s i n g , formada p e l a s s e g u i n t e s e t a p a s : %
28 % %
% Mixagem A n a l o g i c a −−> Amostragem −−> Tx −−> . . . %
30 % . . . −−> Rx −−> I n t e r p o l a c a o −−> F i l t r a g e m . %
% %
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
36
% Limpa a mbiente
38
clear all
40 close all
44
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
46
% Parametros g e r a i s
48
% Discretos
50 %
Fs = 44 e3 ;
52 %
nd = 0 : 4 3 ;
54 nTs = nd/ Fs ;
56 % A n a l o g i c o s
%
58 Fsa = 10 * Fs ;
%
60 n = 0 : 4 3 9 ;
t = n/ Fsa ;
62
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
64
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 155
68 % S i n a i s Tx
70
% Parametros
72
%
74 A1 = 1;
A2 = 1;
76 A3 = 1;
A4 = 1;
78
%
80 f 1 = 2 e3 ;
f2 = 21 e3 ;
82 f 3 = 24 e3 ;
f4 = 40 e3 ;
84
86 % S i n a i s a n a l o g i c o s
88 %
x1 = A1 * c o s ( 2 * p i * f 1 * n/ Fsa ) ;
90 x2 = A2 * c o s ( 2 * p i * f 2 * n/ Fsa ) ;
x3 = A3 * c o s ( 2 * p i * f 3 * n/ Fsa ) ;
92 x4 = A4 * c o s ( 2 * p i * f 4 * n/ Fsa ) ;
94 %
xlow = x1 ;
96 xmed = x2 + x3 ;
xhigh = x4 ;
98
%
100 x = xlow + xmed + xhigh ;
102
% S i n a i s d i s c r e t o s Tx
104
%
106 x1d = A1 * c o s ( 2 * p i * f 1 * nd/ Fs ) ;
x2d = A2 * c o s ( 2 * p i * f 2 * nd/ Fs ) ;
108 x3d = A3 * c o s ( 2 * p i * f 3 * nd/ Fs ) ;
x4d = A4 * c o s ( 2 * p i * f 4 * nd/ Fs ) ;
110
%
112 xlowd = x1d ;
xmedd = x2d + x3d ;
114 xhighd = x4d ;
116 %
xd = xlowd + xmedd + xhighd ;
118
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
120
124 % S i n a i s Rx
126
TET / UFF
156 Capı́tulo 4. Sequências exponenciais
% Parametros
128
%
130 A5 = 1;
A6 = 1;
132
%
134 f 5 = 4 e3 ;
f6 = 20 e3 ;
136
138 % S i n a i s a n a l o g i c o s
140 %
y1 = A1 * c o s ( 2 * p i * f 1 * n/ Fsa ) ;
142 y2 = A2 * c o s ( 2 * p i * f 2 * n/ Fsa ) ;
y5 = A5 * c o s ( 2 * p i * f 5 * n/ Fsa ) ;
144 y6 = A6 * c o s ( 2 * p i * f 6 * n/ Fsa ) ;
y7 = 0 * n ;
146
%
148 ylow = y1 + y5 ;
ymed = y2 + y6 ;
150 yhigh = y7 ;
152 %
y = ylow + ymed + yhigh ;
154
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
156
160 % G r a f i c o s
162
%%%%%%%%%%
164
%
166 % Nota :
%
168 % Foram i n s e r i d o s comandos de ” r e t u r n ” para t e s t e . . .
%
170
%%%%%%%%%%
172
% C o n t r o l e da numeracao dos g r a f i c o s
174
%
176 FigNbr = 0 ;
178 %%%%%%%%%%
180
% L i m i t e s de a b s c i s s a s
182
%
184 min t = min ( t ) ;
max t = max( t ) ;
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 157
186 %
min nTs = min ( nTs ) ;
188 max nTs = max( nTs ) ;
%
190 min n = min ( nd ) ;
max n = max( nd ) ;
192
196 %
min amp = min ( x ) ;
198 max amp = max( x ) ;
200 %%%%%%%%%%
202 %
FigNbr = FigNbr +1;
204 f i g u r e ( FigNbr ) ;
s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
206 %
subplot (4 ,3 ,1)
208 p l o t ( t , x1 )
h o l d on
210 stem ( nd/Fs , x1d )
v = axis ;
212 v ( 1 ) = min t ;
v ( 2 ) = max t ;
214 %v ( 3 ) = min amp ;
%v ( 4 ) = max amp ;
216 a x i s ( v )
t i t l e ( ’ A 1 cos (2 \ pi f 1 t ) ; f 1 = 2 kHz ’ )
218 y l a b e l ( ’ x 1 ( t ) ’ )
%
220 s u b p l o t ( 4 , 3 , 4 )
p l o t ( t , x2 )
222 h o l d on
stem ( nd/Fs , x2d )
224 v = a x i s ;
v ( 1 ) = min t ;
226 v ( 2 ) = max t ;
%v ( 3 ) = min amp ;
228 %v ( 4 ) = max amp ;
axis (v)
230 t i t l e ( ’ A 2 c o s ( 2 \ p i f 2 t ) ; f 2 = 21 kHz ’ )
ylabel ( ’ x 2 ( t ) ’ )
232 %
subplot (4 ,3 ,7)
234 p l o t ( t , x3 )
h o l d on
236 stem ( nd/Fs , x3d )
v = axis ;
238 v ( 1 ) = min t ;
v ( 2 ) = max t ;
240 %v ( 3 ) = min amp ;
%v ( 4 ) = max amp ;
242 a x i s ( v )
t i t l e ( ’ A 3 cos (2 \ pi f 3 t ) ; f 3 = 24 kHz ’ )
244 y l a b e l ( ’ x 3 ( t ) ’ )
TET / UFF
158 Capı́tulo 4. Sequências exponenciais
%
246 subplot (4 ,3 ,10)
p l o t ( t , x4 )
248 h o l d on
stem ( nd/Fs , x4d )
250 v = axis ;
v ( 1 ) = min t ;
252 v ( 2 ) = max t ;
%v ( 3 ) = min amp ;
254 %v ( 4 ) = max amp ;
axis (v)
256 t i t l e ( ’ A 4 cos (2 \ pi f 4 t) ; f 4 = 40 kHz ’ )
ylabel ( ’ x 4 ( t ) ’ )
258 %
xlabel ( ’ t ’ )
260 %
subplot (4 ,3 ,2)
262 stem ( nd/Fs , x1d , ’ r ’ )
v = axis ;
264 v ( 1 ) = min t ;
v ( 2 ) = max t ;
266 %v ( 3 ) = min amp ;
%v ( 4 ) = max amp ;
268 axis (v)
t i t l e ( ’ A 1 cos (2 \ pi f 1 n T S) ; F S = 44 kHz ’ )
270 ylabel ( ’ x 1 (n T S) ’ )
%
272 subplot (4 ,3 ,5)
stem ( nd/Fs , x2d , ’ r ’ )
274 v = axis ;
v ( 1 ) = min t ;
276 v ( 2 ) = max t ;
%v ( 3 ) = min amp ;
278 %v ( 4 ) = max amp ;
axis (v)
280 t i t l e ( ’ A 2 cos (2 \ pi f 2 n T S) ; F S = 44 kHz ’ )
ylabel ( ’ x 2 (n T S) ’ )
282 %
subplot (4 ,3 ,8)
284 stem ( nd/Fs , x3d , ’ r ’ )
v = axis ;
286 v ( 1 ) = min t ;
v ( 2 ) = max t ;
288 %v ( 3 ) = min amp ;
%v ( 4 ) = max amp ;
290 axis (v)
t i t l e ( ’ A 3 cos (2 \ pi f 3 n T S) ; F S = 44 kHz ’ )
292 ylabel ( ’ x 3 (n T S) ’ )
%
294 subplot (4 ,3 ,11)
stem ( nd/Fs , x4d , ’ r ’ )
296 v = axis ;
v ( 1 ) = min t ;
298 v ( 2 ) = max t ;
%v ( 3 ) = min amp ;
300 %v ( 4 ) = max amp ;
axis (v)
302 t i t l e ( ’ A 4 cos (2 \ pi f 4 n T S) ; F S = 44 kHz ’ )
ylabel ( ’ x 4 (n T S) ’ )
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 159
304 %
xlabel ( ’n T S ’ )
306 %
subplot (4 ,3 ,9)
308 p l o t ( t , y6 )
h o l d on
310 stem ( nd/Fs , x3d )
v = axis ;
312 v ( 1 ) = min t ;
v ( 2 ) = max t ;
314 %v ( 3 ) = min amp ;
%v ( 4 ) = max amp ;
316 a x i s ( v )
t i t l e ( ’ A 6 cos (2 \ pi f 6 t ) ; f 6 = 20 kHz ’ )
318 y l a b e l ( ’ y 6 ( t ) ’ )
%
320 s u b p l o t ( 4 , 3 , 1 2 )
p l o t ( t , y5 )
322 h o l d on
stem ( nd/Fs , x4d )
324 v = a x i s ;
v ( 1 ) = min t ;
326 v ( 2 ) = max t ;
%v ( 3 ) = min amp ;
328 %v ( 4 ) = max amp ;
axis (v)
330 t i t l e ( ’ A 5 c o s ( 2 \ p i f 5 t ) ; f 5 = 4 kHz ’ )
ylabel ( ’ y 5 ( t ) ’ )
332 %
xlabel ( ’ t ’ )
334 %
% I n s e r c a o nao c o n v e n c i o n a l de t e x t o . . .
336 %
% Subplot vazio . . .
338 s u b p l o t ( 4 , 3 , 3 )
a x i s ( ” o f f ”)
340 % D e f i n i c a o de c e l l a r r a y com s t r i n g s de comprimentos d i f e r e n t e s . . .
t i t l e s t r = { ’ * S i n a i s a n a l ó g i c o s em a z u l . ’ ,
342 ’ ’ ,
’ * S i n a i s d i s c r e t o s em vermelho . ’ } ;
344 % I n s e r c a o de t e x t o no t i t u l o de s u b p l o t v a z i o . . .
hdl = t i t l e ( t i t l e s t r ,
346 ”f o n t s i z e ” ,14 ,
”horizontalalignment ” , ” l e f t ” ,
348 ” v e r t i c a l a l i g n m e n t ” , ”top ” ) ;
t i t l e p o s i t i o n = g e t ( hdl , ” p o s i t i o n ” ) ;
350 t i t l e p o s i t i o n ( 1 ) = 0 ;
s e t ( hdl , ” p o s i t i o n ” , t i t l e p o s i t i o n )
352 %
%r e t u r n
354
%%%%%%%%%%
356
%
358 FigNbr = FigNbr +1;
f i g u r e ( FigNbr ) ;
360 s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
%
362 s u b p l o t ( 3 , 4 , 1 )
TET / UFF
160 Capı́tulo 4. Sequências exponenciais
p l o t ( t , x1 )
364 v = axis ;
v ( 1 ) = min t ;
366 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
368 v ( 4 ) = max amp ;
axis (v)
370 t i t l e ( ’ A 1 cos (2 \ pi f 1 t) ; f 1 = 2 kHz ’ )
ylabel ( ’ x 1 ( t ) ’ )
372 %
xlabel ( ’ t ’ )
374 %
subplot (3 ,4 ,2)
376 p l o t ( t , x2 )
v = axis ;
378 v ( 1 ) = min t ;
v ( 2 ) = max t ;
380 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
382 axis (v)
t i t l e ( ’ A 2 cos (2 \ pi f 2 t) ; f 2 = 21 kHz ’ )
384 ylabel ( ’ x 2 ( t ) ’ )
%
386 xlabel ( ’ t ’ )
%
388 subplot (3 ,4 ,3)
p l o t ( t , x3 )
390 v = axis ;
v ( 1 ) = min t ;
392 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
394 v ( 4 ) = max amp ;
axis (v)
396 t i t l e ( ’ A 3 cos (2 \ pi f 3 t) ; f 3 = 24 kHz ’ )
ylabel ( ’ x 3 ( t ) ’ )
398 %
xlabel ( ’ t ’ )
400 %
subplot (3 ,4 ,4)
402 p l o t ( t , x4 )
v = axis ;
404 v ( 1 ) = min t ;
v ( 2 ) = max t ;
406 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
408 axis (v)
t i t l e ( ’ A 4 cos (2 \ pi f 4 t) ; f 4 = 40 kHz ’ )
410 ylabel ( ’ x 4 ( t ) ’ )
%
412 xlabel ( ’ t ’ )
%
414 subplot (3 ,4 ,5)
stem ( nd , x1d , ’ r ’ )
416 v = axis ;
v ( 1 ) = min n ;
418 v ( 2 ) = max n ;
v ( 3 ) = min amp ;
420 v ( 4 ) = max amp ;
axis (v)
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 161
TET / UFF
162 Capı́tulo 4. Sequências exponenciais
v = axis ;
482 v ( 1 ) = min t ;
v ( 2 ) = max t ;
484 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
486 axis (v)
t i t l e ( ’ A 5 cos (2 \ pi f 5 t ) ; f 5 = 4 kHz ’ )
488 ylabel ( ’ y 5 ( t ) ’ )
%
490 xlabel ( ’ t ’ )
%
492 %r e t u r n
494 %%%%%%%%%%
496 %
FigNbr = FigNbr +1;
498 f i g u r e ( FigNbr ) ;
s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
500 %
subplot (3 ,4 ,1)
502 p l o t ( t , x1 )
v = axis ;
504 v ( 1 ) = min t ;
v ( 2 ) = max t ;
506 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
508 a x i s ( v )
t i t l e ( ’ A 1 cos (2 \ pi f 1 t ) ; f 1 = 2 kHz ’ )
510 y l a b e l ( ’ x 1 ( t ) ’ )
%
512 s u b p l o t ( 3 , 4 , 9 )
p l o t ( t , xlow )
514 v = a x i s ;
v ( 1 ) = min t ;
516 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
518 v ( 4 ) = max amp ;
axis (v)
520 t i t l e ( ’ S i n a l Tx ( low ) ’ )
y l a b e l ( ’ x { low } ( t ) ’ )
522 %
xlabel ( ’ t ’ )
524 %
subplot (3 ,4 ,2)
526 p l o t ( t , x2 )
v = axis ;
528 v ( 1 ) = min t ;
v ( 2 ) = max t ;
530 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
532 a x i s ( v )
t i t l e ( ’ A 2 cos (2 \ pi f 2 t ) ; f 2 = 21 kHz ’ )
534 y l a b e l ( ’ x 2 ( t ) ’ )
%
536 s u b p l o t ( 3 , 4 , 6 )
p l o t ( t , x3 )
538 v = a x i s ;
v ( 1 ) = min t ;
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 163
540 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
542 v ( 4 ) = max amp ;
axis (v)
544 t i t l e ( ’ A 3 cos (2 \ pi f 3 t ) ; f 3 = 24 kHz ’ )
ylabel ( ’ x 3 ( t ) ’ )
546 %
subplot (3 ,4 ,10)
548 p l o t ( t , xmed )
v = axis ;
550 v ( 1 ) = min t ;
v ( 2 ) = max t ;
552 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
554 axis (v)
t i t l e ( ’ S i n a l Tx (med) ’ )
556 y l a b e l ( ’ x {med} ( t ) ’ )
%
558 xlabel ( ’ t ’ )
%
560 subplot (3 ,4 ,3)
p l o t ( t , x4 )
562 v = axis ;
v ( 1 ) = min t ;
564 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
566 v ( 4 ) = max amp ;
axis (v)
568 t i t l e ( ’ A 4 cos (2 \ pi f 4 t ) ; f 4 = 40 kHz ’ )
ylabel ( ’ x 4 ( t ) ’ )
570 %
subplot (3 ,4 ,11)
572 p l o t ( t , xhigh )
v = axis ;
574 v ( 1 ) = min t ;
v ( 2 ) = max t ;
576 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
578 axis (v)
t i t l e ( ’ S i n a l Tx ( h i g h ) ’ )
580 y l a b e l ( ’ x { high } ( t ) ’ )
%
582 xlabel ( ’ t ’ )
%
584 subplot (3 ,4 ,12)
plot ( t , x)
586 v = axis ;
v ( 1 ) = min t ;
588 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
590 v ( 4 ) = max amp ;
axis (v)
592 t i t l e ( ’ S i n a l Tx ( low + med + h i g h ) ’ )
ylabel ( ’x ( t ) ’ )
594 %
xlabel ( ’ t ’ )
596 %
%r e t u r n
598
TET / UFF
164 Capı́tulo 4. Sequências exponenciais
%%%%%%%%%%
600
%
602 FigNbr = FigNbr +1;
f i g u r e ( FigNbr ) ;
604 s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
%
606 subplot (4 ,1 ,1)
plot ( t , x , ’b ’ )
608 v = axis ;
v ( 1 ) = min t ;
610 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
612 v ( 4 ) = max amp ;
axis (v)
614 t i t l e ( ’ S i n a l Tx ’ )
ylabel ( ’x ( t ) ’ )
616 %
subplot (4 ,1 ,2)
618 stem ( nTs , xd , ’ r ’ )
v = axis ;
620 v ( 1 ) = min nTs ;
v ( 2 ) = max nTs ;
622 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
624 axis (v)
t i t l e ( ’ S i n a l D i s c r e t o Tx ’ )
626 ylabel ( ’x (n T s ) ’ )
%
628 subplot (4 ,1 ,3)
plot ( t , y , ’k ’ )
630 v = axis ;
v ( 1 ) = min t ;
632 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
634 v ( 4 ) = max amp ;
axis (v)
636 t i t l e ( ’ S i n a l Rx ’ )
ylabel ( ’y ( t ) ’ )
638 %
subplot (4 ,1 ,4)
640 plot ( t , x , ’b ’ )
h o l d on
642 stem ( nTs , xd , ’ r ’ )
plot ( t , y , ’k ’ )
644 v = axis ;
v ( 1 ) = min t ;
646 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
648 v ( 4 ) = max amp ;
axis (v)
650 t i t l e ( ’ S u p e r p o s i ç ã o dos t r ê s s i n a i s ’ )
%
652 xlabel ( ’ t ’ )
%
654 %r e t u r n
656 %%%%%%%%%%
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 165
658 %
FigNbr = FigNbr +1;
660 f i g u r e ( FigNbr ) ;
s e t ( g c f , ”p a p e r t y p e ” , ”a4 ”)
662 %
subplot (3 ,4 ,2)
664 p l o t ( t , y1 )
v = axis ;
666 v ( 1 ) = min t ;
v ( 2 ) = max t ;
668 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
670 a x i s ( v )
t i t l e ( ’ A 1 cos (2 \ pi f 1 t ) ; f 1 = 2 kHz ’ )
672 y l a b e l ( ’ y 1 ( t ) ’ )
%
674 s u b p l o t ( 3 , 4 , 3 )
p l o t ( t , y2 )
676 v = a x i s ;
v ( 1 ) = min t ;
678 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
680 v ( 4 ) = max amp ;
axis (v)
682 t i t l e ( ’ A 2 c o s ( 2 \ p i f 2 t ) ; f 2 = 21 kHz ’ )
ylabel ( ’ y 2 ( t ) ’ )
684 %
subplot (3 ,4 ,10)
686 p l o t ( t , ylow )
v = axis ;
688 v ( 1 ) = min t ;
v ( 2 ) = max t ;
690 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
692 a x i s ( v )
t i t l e ( ’ S i n a l Rx ( low ) ’ )
694 y l a b e l ( ’ y { low } ( t ) ’ )
%
696 x l a b e l ( ’ t ’ )
%
698 s u b p l o t ( 3 , 4 , 6 )
p l o t ( t , y5 )
700 v = a x i s ;
v ( 1 ) = min t ;
702 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
704 v ( 4 ) = max amp ;
axis (v)
706 t i t l e ( ’ A 5 c o s ( 2 \ p i f 5 t ) ; f 5 = 4 kHz ’ )
ylabel ( ’ y 5 ( t ) ’ )
708 %
subplot (3 ,4 ,7)
710 p l o t ( t , y6 )
v = axis ;
712 v ( 1 ) = min t ;
v ( 2 ) = max t ;
714 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
716 a x i s ( v )
TET / UFF
166 Capı́tulo 4. Sequências exponenciais
t i t l e ( ’ A 6 cos (2 \ pi f 6 t ) ; f 6 = 20 kHz ’ )
718 ylabel ( ’ y 6 ( t ) ’ )
%
720 subplot (3 ,4 ,11)
p l o t ( t , ymed )
722 v = axis ;
v ( 1 ) = min t ;
724 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
726 v ( 4 ) = max amp ;
axis (v)
728 t i t l e ( ’ S i n a l Rx (med) ’ )
y l a b e l ( ’ y {med} ( t ) ’ )
730 %
xlabel ( ’ t ’ )
732 %
subplot (3 ,4 ,4)
734 p l o t ( t , y7 )
v = axis ;
736 v ( 1 ) = min t ;
v ( 2 ) = max t ;
738 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
740 axis (v)
t i t l e ( ’ S i n a l nulo ’ )
742 ylabel ( ’ y 7 ( t ) ’ )
%
744 subplot (3 ,4 ,12)
p l o t ( t , yhigh )
746 v = axis ;
v ( 1 ) = min t ;
748 v ( 2 ) = max t ;
v ( 3 ) = min amp ;
750 v ( 4 ) = max amp ;
axis (v)
752 t i t l e ( ’ S i n a l Rx ( h i g h ) ’ )
y l a b e l ( ’ y { high } ( t ) ’ )
754 %
xlabel ( ’ t ’ )
756 %
subplot (3 ,4 ,9)
758 plot ( t , y)
v = axis ;
760 v ( 1 ) = min t ;
v ( 2 ) = max t ;
762 v ( 3 ) = min amp ;
v ( 4 ) = max amp ;
764 axis (v)
t i t l e ( ’ S i n a l Rx ( low + med + h i g h ) ’ )
766 ylabel ( ’y ( t ) ’ )
%
768 xlabel ( ’ t ’ )
%
770 %r e t u r n
772 %%%%%%%%%%
A.S.V.
4.3. Efeitos das caracterı́sticas relevantes de exponenciais 167
776
%
778 % EOF
%
TET / UFF
168 Capı́tulo 4. Sequências exponenciais
A.S.V.
Parte III
Representações de um SLIT
169
Capı́tulo 5
Representações de um SLIT
5.1 Introdução
Diversas descrições para os sistemas do tipo SLIT, Sistema Linear Invariante ao Tempo (ou
ao deslocamento), são abordadas na terceira parte do curso.
No domı́nio do tempo, são discutidas as seguintes representações: resposta ao impulso,
equação de diferença, operador de transferência, equações de estado, diagrama de sistema (ou
realização ou estrutura).
Nas seções que se seguem, são apresentadas diversas listagens de programas, relativas a tais
representações.
7
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9 % %
% DSP : Demo s o b r e t r a c a d o de DPZ, %
11 % com s i n a l i z a c a o de s i n g u l a r i d a d e s m u l t i p l a s . %
% %
13 % Autor : A l e x a n d r e S . de l a Vega . %
% %
15 % Datas : /2018−1/ %
% %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19 %
171
172 Capı́tulo 5. Representações de um SLIT
23 % lim p a wo rkspa ce
clear all
25 c l o s e a l l
27 %
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
29 %
31 % c a l c u l a c i r c u l o de r a i o u n i t a r i o
N = 360;
33 n = 0 : ( N−1);
u n i t c i r c = exp ( j * 2 * p i * n/N ) ;
35
%
37 %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
%
39
% d e f i n e funcao p o l in o m i a l r a c i o n a l
41 % para t e s t e s . . .
43 % numerador
%
45 %num = [ 5 4 3 2 1 ] ;
%
47 num = [ 1 2 3 4 5 ] ;
%num = [ 1 2 3 4 ] ;
49 %num = [ 1 2 ] ;
%num = 1 ;
51 %
%num = [ 1 1 . 2 5 ] ;
53 %
% e r r o numerico em r o o t s ( )
55 % g e r a 2 z e r o s s i m p l e s
% ao i n v e s de 1 p o l o m u l t i p l o com m=2 . . .
57 %num = [ 1 . 0 0 0 0 0 2.50000 2.00000 0.50000 ] ;
59 % denominador
%
61 den = [ 5 4 3 2 1 ] ;
%den = [ 5 4 3 2 ] ;
63 %den = [ 5 4 3 ] ;
%den = [ 5 4 ] ;
65 %den = 5 ;
%
67 %den = [ 1 −1 . 2 5 ] ;
%
69
%
71 %%%%%%%%%%
%
73
nc = [ 1 . 9 ] ;
75 np = [ 1 . 8 ] ;
nf = [ 1 .5 ] ;
77
num = conv ( [ 1 0 ] , conv ( nc , np ) ) ;
A.S.V.
5.2. Operador de transferência 173
81 %
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
83 %
85 % c a l c u l a z e r o s , p o l o s e c o n s t a n t e de ganho
z = r o o t s (num ) ;
87 p = r o o t s ( den ) ;
k = num( 1 ) / den ( 1 ) ;
89
%
91 %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
%
93
% define zeros e polos
95 % para t e s t e s . . .
%
97 % z e r o s m u l t i p l o s
%z = [ . 2 . 3 . 1 . 2 . 3 . 3 . 3 . 1 . 2 ] ’ ;
99 %
% polos multiplos
101 %p = [ −.3 −.3 * i −.3+.3 * i , . . .
% −.1 −.1 * i −.1+.1 * i , . . .
103 % −.2 −.2 * i −.2+.2 * i , . . .
% −.2 −.2 * i −.2+.2 * i , . . .
105 % −.3 −.3 * i −.3+.3 * i , . . .
% −.3 −.3 * i −.3+.3 * i , . . .
107 % −.3 −.3 * i −.3+.3 * i , . . .
% −.1 −.1 * i −.1+.1 * i , . . .
109 % −.2 −.2 * i −.2+.2 * i , . . .
% 0] ’;
111
%
113 %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
%
115
% g e r e n c i a as s i n g u l a r i d a d e s s i m p l e s e m u l t i p l a s
117
% zeros
119 %
% s e l e c i o n a os d i f e r e n t e s v a l o r e s de z e r o s
121 z unq = unique ( z ) ;
123 % s e p a r a os z e r o s s i m p l e s dos m u l t i p l o s
% e
125 % i d e n t i f i c a as m u l t i p l i c i d a d e s
%
127 z smp = [ ] ;
z mlt = [ ] ;
129 z mlt m = [ ] ;
%
131 f o r i n d = 1 : l e n g t h ( z unq )
unq pos = f i n d ( z == z unq ( i n d ) ) ;
133 m = l e n g t h ( unq pos ) ;
i f ( m == 1 )
135 z smp = [ z smp ; z unq ( i n d ) ] ;
else
137 z mlt = [ z mlt ; z unq ( i n d ) ] ;
TET / UFF
174 Capı́tulo 5. Representações de um SLIT
z mlt m = [ z mlt m ; m ];
139 endif
endfor
141 %
c l e a r unq pos m
143
% polos
145 %
% s e l e c i o n a os d i f e r e n t e s v a l o r e s de p o l o s
147 p unq = unique ( p ) ;
149 % s e p a r a os p o l o s s i m p l e s dos m u l t i p l o s
% e
151 % i d e n t i f i c a as m u l t i p l i c i d a d e s
%
153 p smp = [ ] ;
p mlt = [ ] ;
155 p mlt m = [ ] ;
%
157 f o r i n d = 1 : l e n g t h ( p unq )
unq pos = f i n d ( p == p unq ( i n d ) ) ;
159 m = l e n g t h ( unq pos ) ;
i f ( m == 1 )
161 p smp = [ p smp ; p unq ( i n d ) ] ;
else
163 p mlt = [ p mlt ; p unq ( i n d ) ] ;
p mlt m = [ p mlt m ; m ];
165 endif
endfor
167 %
c l e a r unq pos m
169
%
171 %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
%
173
%
175 % c r i a g r a f i c o
%
177
% c a l c u l o s comuns a t o d o s os g r a f i c o s
179 %
r e z u n q = r e a l ( z unq ) ;
181 im z unq = imag ( z unq ) ;
%
183 r e p u n q = r e a l ( p unq ) ;
im p unq = imag ( p unq ) ;
185 %
mult offset x = .025;
187 m u l t o f f s e t y = . 0 5 0 ;
189 % c a l c u l a r a i o de v i s u a l i z a c a o ,
% b a s e a d o na p o s i c a o das s i n g u l a r i d a d e s ( z e r o s e p o l o s )
191 %
i f ( isempty ( z ) && isempty ( p ) )
193 dpz limit = 1;
else
195 m a x r e s i n g = max( [ max( abs ( r e z u n q ) ) , max( abs ( r e p u n q ) ) ] ) ;
max im sing = max( [ max( abs ( im z unq ) ) , max( abs ( im p unq ) ) ] ) ;
A.S.V.
5.2. Operador de transferência 175
201 % c r i a canvas
h f=f i g u r e ( 1 ) ;
203 s e t ( hf , ’ p a p e r t y p e ’ , ’ a4 ’ )
205 % desenha c i r c u l o de r a i o u n i t a r i o
p l o t ( r e a l ( u n i t c i r c ) , imag ( u n i t c i r c ) , ’ b ’ )
207
% mantem t o d o s os g r a f i c o s na mesma f i g u r a
209 h o l d on
211 % desenha os z e r o s s i m p l e s
p l o t ( r e a l ( z smp ) , imag ( z smp ) , ’ ok ’ )
213
% desenha os z e r o s m u l t i p l o s
215 p l o t ( r e a l ( z m l t ) , imag ( z m l t ) , ’ ok ’ )
f o r i n d = 1 : l e n g t h ( z mlt m )
217 text ( ( r e a l ( z mlt ( ind ) ) + m u l t o f f s e t x ) ,
( imag ( z m l t ( i n d ) ) + m u l t o f f s e t y ) ,
219 num2str ( z mlt m ( i n d ) ) )
endfor
221
% desenha os p o l o s s i m p l e s
223 p l o t ( r e a l ( p smp ) , imag ( p smp ) , ’ xk ’ )
225 % desenha os p o l o s m u l t i p l o s
p l o t ( r e a l ( p mlt ) , imag ( p mlt ) , ’ xk ’ )
227 f o r i n d = 1 : l e n g t h ( p mlt m )
t e x t ( ( r e a l ( p mlt ( i n d ) ) + m u l t o f f s e t x ) ,
229 ( imag ( p mlt ( i n d ) ) + m u l t o f f s e t y ) ,
num2str ( p mlt m ( i n d ) ) )
231 e n d f o r
233 % e s c r e v e c o n s t a n t e de ganho
% em p o s i c a o d e f i n i d a p e l o s l i m i t e s do g r a f i c o
235 K s t r = [ ’K = ’ , s p r i n t f ( ”%.3 f ” , k ) ] ;
K str offset = dpz limit / 8;
237 t e x t ( ((− d p z l i m i t ) + K s t r o f f s e t ) ,
(( dpz limit ) − K str offset ) ,
239 K str )
241 % i d e n t i f i c a o g r a f i c o
t i t l e ( ’ Diagrama de p o l o s e z e r o s (DPZ) ’ )
243 y l a b e l ( ’ Im \ { . \ } ’ )
x l a b e l ( ’ Re \ { . \ } ’ )
245
% h a b i l i t a o g r i d na f i g u r a
247 g r i d on
249 % C o n t r o l a formato do g r a f i c o
% Deve v i r ANTES do c o n t r o l e dos l i m i t e s ! ! !
251 a x i s ( ”image ”)
253 % c o n t r o l a l i m i t e s
v = [ (− d p z l i m i t ) d p z l i m i t (− d p z l i m i t ) d p z l i m i t ] ;
255 a x i s ( v )
TET / UFF
176 Capı́tulo 5. Representações de um SLIT
257 %
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
259 %
261 %
% EOF
263 %
A.S.V.
Parte IV
177
Capı́tulo 6
6.1 Introdução
Na terceira parte do curso, são abordados os seguintes itens sobre sinais (com tempo dis-
creto) no domı́nio da frequência: revisão das representações em frequência com tempo contı́nuo
(Série de Fourier, Transformada de Fourier, Transformada de Laplace), Série de Fourier de
Tempo Discreto (DTFS), Transformada de Fourier de Tempo Discreto (DTFT), Transformada
de Fourier Discreta (DFT), Transformada Rápida de Fourier (FFT), Transformada Z, relações
entre as diversas representações, parâmetros e efeitos importantes. Além disso, são também
abordados os seguintes tópicos sobre SLIT (com tempo discreto) no domı́nio da frequência:
Resposta em Frequência, Seletividade em Frequência, Função de Transferência ou Função de
Sistema, representações de um SLIT no domı́nio da frequência. Nas seções que se seguem, são
apresentadas diversas listagens de programas, relativas a tais assuntos.
6.2 DTFS
• O Código 6.1 apresenta o cálculo dos coeficientes da DTFS de um sinal discreto periódico.
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DTFS example %
11 % %
% Author : A l e x a n d r e S . de l a Vega %
13 % Version : /2022 0 1 1 2 / %
% /2010 1 2 1 4 / %
15 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 %
179
180 Capı́tulo 6. Sinais no domı́nio da frequência
21 % c l e a r wo rksp a ce
clear all
23 c l o s e a l l
27 % d e f i n e i n p u t s e q u e n c e
%
29 x f u n d n = rand ( 1 , 1 0 ) ;
%
31 x f u n d n = 5: −1: −10;
x f u n d n = 10: −1: −5;
33 %
%x f u n d n = 10: −1: −10;
35 %x f u n d n = 1 0 : − 1 : 0 ;
%x f u n d n = 0: −1: −10;
37
%
39 N = l e n g t h ( x f u n d n ) ;
43 % c a l c u l a t e DTFS c o e f i c i e n t s
X fund k = z e r o s ( 1 ,N ) ;
45 f o r k = 0 : ( N−1)
i n d = k+1;
47 f o r n = 0 : ( N−1)
X fund k ( i n d ) = X fund k ( i n d ) + . . .
49 ( x f u n d n ( n+1) * exp ( j * k * ( ( 2 * p i ) /N) * n ) ) ;
end
51 end
X fund k = X fund k / N;
53 X fund k mod = abs ( X fund k ) ;
X fund k deg = ( a n g l e ( X fund k ) * 1 8 0 ) / p i ;
55
%%%%%%%%%% %%%%%%%%%% %%%%%%%%%%
57
%
59 % draw s e q u e n c e s
%
61
%%%%%%%%%% %%%%%%%%%%
63
%
65 FigNbr = 0 ;
67 %
bck clr = [.1 , .1 , . 1 ] ;
69
%
71 n = 0 : ( N−1);
k = 0 : ( N−1);
73
%
75 %abs min = min ( a b s ( x f u n d n ) ) ;
abs max = max( abs ( x f u n d n ) ) ;
77
%
79 %v a l m i n = min ( x f u n d n ) ;
A.S.V.
6.2. DTFS 181
91 %%%%%%%%%% %%%%%%%%%%
93 %
FigNbr = FigNbr +1;
95 f i g u r e ( FigNbr )
%
97 %
subplot (2 ,4 ,1)
99 stem ( n per , x p e r n )
a x i s ( [ n p e r ( 1 ) n p e r ( end ) −abs max abs max ] )
101 s e t ( gca , ” c o l o r ” , b c k c l r )
y l a b e l ( ’ x { per } [ n ] ’ )
103 x l a b e l ( ’ n ’ )
t i t l e ({ ’ P e r i o d i c s i g n a l ’ , ’ x { per } [ n ] ’ })
105 %
%
107 s u b p l o t ( 2 , 4 , 2 )
stem ( n , x f u n d n )
109 a x i s ( [ n ( 1 ) n ( end ) −abs max abs max ] )
s e t ( gca , ” c o l o r ” , b c k c l r )
111 y l a b e l ( ’ x { fund } [ n ] ’ )
xlabel ( ’n ’ )
113 t i t l e ( { ’ R e p r e s e n t a t i o n o f a p e r i o d i c s i g n a l ’ ,
’ Time ( n ) ’ } )
115 %
%
117 s u b p l o t ( 2 , 4 , 3 )
stem ( k , X fund k mod )
119 a x i s ( [ k ( 1 ) k ( end ) 0 abs max ] )
s e t ( gca , ” c o l o r ” , b c k c l r )
121 y l a b e l ( ’ | X { fund } [ k ] | ’ )
t i t l e ({ ’ Representation of a p e r i o d i c s i g n a l ’ ,
123 ’ Frequency ( k ) ’ } )
%
125 s u b p l o t ( 2 , 4 , 7 )
stem ( k , X fund k deg )
127 a x i s ( [ k ( 1 ) k ( end ) −200 200 ] )
s e t ( gca , ” c o l o r ” , b c k c l r )
129 y l a b e l ( ’ \ a n g l e X { fund } [ k ] ( degree ) ’ )
xlabel ( ’k ’ )
131 %
%
133 s u b p l o t ( 2 , 4 , 4 )
stem ( k per , X per k mod )
135 a x i s ( [ k ( 1 ) k p e r ( end ) 0 abs max ] )
s e t ( gca , ” c o l o r ” , b c k c l r )
137 y l a b e l ( ’ | X { p e r } [ k ] | ’ )
t i t l e ({ ’ P e r i o d i c s i g n a l ’ , ’X { per } [ k ] ’ })
TET / UFF
182 Capı́tulo 6. Sinais no domı́nio da frequência
139 %
subplot (2 ,4 ,8)
141 stem ( k per , X p e r k d e g )
a x i s ( [ k p e r ( 1 ) k p e r ( end ) −200 200 ] )
143 s e t ( gca , ” c o l o r ” , b c k c l r )
y l a b e l ( ’ \ angle X { per } [ k ] ( degree ) ’ )
145 x l a b e l ( ’ k ’ )
149 %
% EOF
151 %
A.S.V.
6.3. DTFT 183
6.3 DTFT
• O Código 6.2 implementa o cálculo da DTFT de um sinal discreto não periódico, com
simetria par.
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % T i t u l o : Demo de DTFT %
% de s e q üê n c i a com s i m e t r i a par %
13 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
15 % Data : / 2010 02 / %
% %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
19
21 % Limpeza do a mbiente
clear all
23 c l o s e a l l
25 %
n = −10:10;
27 x1n = (−2<=n ) & ( n<=2);
x2n = (0<=n ) & ( n<=4);
29
31 %
k = −1:.01:1;
33 W = p i * k ;
35 %
X1W = ( 1 + c o s (W) + c o s ( 2 *W) ) ;
37 X1Wmod = abs (X1W) ;
X1Wang = a n g l e (X1W) ;
39
X2W = ( 1 + c o s (W) + c o s ( 2 *W) ) . * exp(− j * 4 *W) ;
41 X2Wmod = abs (X2W) ;
X2Wang = unwrap ( a n g l e (X2W) ) ;
43
45 %
figure (1)
47 %
subplot (3 ,2 ,1)
49 stem ( n , x1n )
ylabel ( ’x(n) ’ )
51 x l a b e l ( ’ n ’ )
t i t l e ( ’DTFT de s i n a l com s i m e t r i a par ’ )
TET / UFF
184 Capı́tulo 6. Sinais no domı́nio da frequência
53 %
subplot (3 ,2 ,3)
55 p l o t ( k ,X1Wmod)
y l a b e l ( ’ |X( \Omega ) | ’ )
57 x l a b e l ( ’ \Omega / \ p i ’ )
%
59 s u b p l o t ( 3 , 2 , 5 )
p l o t ( k , X1Wang)
61 y l a b e l ( ’ \ a n g l e X( \Omega) ’ )
x l a b e l ( ’ \Omega / \ p i ’ )
63
%
65 s u b p l o t ( 3 , 2 , 2 )
stem ( n , x2n )
67 y l a b e l ( ’ x ( n ) ’ )
xlabel ( ’n ’ )
69 t i t l e ( ’DTFT de s i n a l com s i m e t r i a par ’ )
%
71 s u b p l o t ( 3 , 2 , 4 )
p l o t ( k ,X2Wmod)
73 y l a b e l ( ’ |X( \Omega ) | ’ )
x l a b e l ( ’ \Omega / \ p i ’ )
75 %
subplot (3 ,2 ,6)
77 p l o t ( k , X2Wang)
y l a b e l ( ’ \ a n g l e X( \Omega) ’ )
79 x l a b e l ( ’ \Omega / \ p i ’ )
81
%
83 % EOF
%
A.S.V.
6.4. DTFS × DTFT × DFT 185
Código 6.3: Cálculo de DTFS, DTFT e DFT, para sequência gate retangular.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
% Arquivo : d t f s d t f t d f t g a t e r e t a n g u l a r .m
4 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6
8 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % %
% T i t u l o : C a l c u l o de DTFS, DTFT e DFT %
12 % de uma s e q u e n c i a g a t e r e t a n g u l a r . %
% %
14 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Data : / 2011 1 1 2 9 / %
16 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18 %
20
% l i m p e z a do ambiente de t r a b a l h o
22 % v a r i a v e i s
clear all
24 % j a n e l a s
close all
26
28 % d e f i n i c a o dos p ar amet ro s
Ng = 3 ; % comprimento do g a t e = 2Ng + 1
30 %
Np = 2 0 ; % p e r i o d o f u n d a m e n t a l de r e p e t i c a o
32 %
Nv = 2 * Np ;
34 n = −Nv : Nv ; % j a n e l a de v i s u a l i z a c a o
%
36
38 % d e f i n i c a o da s e q u e n c i a nao p e r i o d i c a
xn = g a t e r e t a n g u n i t a r i o (Ng , n ) ;
40
42 % d e f i n i c a o da s e q u e n c i a p e r i o d i c a
xp = g a t e r e t a n g u n i t a r i o (Ng , n ) ;
44 l =1;
w h i l e ( ( l *Np − Ng) < Nv ) ,
46 xp = xp + g a t e r e t a n g u n i t a r i o (Ng , ( n + l *Np ) ) ;
xp = xp + g a t e r e t a n g u n i t a r i o (Ng , ( n − l *Np ) ) ;
48 l = l + 1;
end
50
52 % d e f i n i c a o do Omega k = dW
TET / UFF
186 Capı́tulo 6. Sinais no domı́nio da frequência
dW = ( 2 * p i /Np ) ;
54
56 % d e f i n i c a o da DTFS
k = n;
58 i n d 0 = f i n d ( k==0);
k ( i n d 0 )= Np ; % e v i t a d i v i s a o por zero ,
60 % p o i s s i n (2 * p i ) ˜= s i n ( 0 )
% por e r r o de c a l c u l o numerico
62 Wk = k *dW;
xkp = ( s i n ( ( 2 * Ng + 1 ) * (Wk/ 2 ) ) . / s i n (Wk/ 2 ) ) / Np ;
64 k ( i n d 0 )= 0 ; % r e s t a u r a v a l o r o r i g i n a l para v e t o r ( 0 )
66
% d e f i n i c a o da DTFT
68 l = −Nv : ( Np/ 5 0 0 ) : Nv ;
i n d 0 = f i n d ( l ==0);
70 l ( i n d 0 )= Np ; % e v i t a d i v i s a o por zero ,
% p o i s s i n (2 * p i ) ˜= s i n ( 0 )
72 % por e r r o de c a l c u l o numerico
W = l *dW;
74 xW = ( s i n ( ( 2 * Ng + 1 ) * (W/ 2 ) ) . / s i n (W/ 2 ) ) ;
l ( i n d 0 )= 0 ; % r e s t a u r a v a l o r o r i g i n a l para v e t o r ( 0 )
76
78 % d e f i n i c a o da DFT
xk = z e r o s ( 1 , l e n g t h ( k ) ) ;
80 krange = ( 1 : Np) + Nv ;
xk ( krange ) = Np * xkp ( krange ) ;
82
84 %%%%%%%%%%%%%%%%%%%%%%%
86
% ilustra resultados
88
%a x i s ( [XMIN XMAX YMIN YMAX] )
90
figure (1)
92 %
%s u b p l o t ( 2 , 3 , 1 )
94 s u b p l o t ( 3 , 2 , 1 )
stem ( n , xp , ’ k ’ )
96 y l a b e l ( ’ x p [ n ] ’ )
xlabel ( ’n ’ )
98 t i t l e ( ’ S i n a l p e r i ó d i c o ’ )
%
100 %s u b p l o t ( 2 , 3 , 2 )
subplot (3 ,2 ,3)
102 stem ( n , xn , ’ k ’ )
ylabel ( ’x [n] ’ )
104 x l a b e l ( ’ n ’ )
t i t l e ( ’ S i n a l nã o p e r i ó d i c o ’ )
106 %
%s u b p l o t ( 2 , 3 , 3 )
108 s u b p l o t ( 3 , 2 , 5 )
stem ( n , xn , ’ k ’ )
110 y l a b e l ( ’ x [ n ] ’ )
xlabel ( ’n ’ )
A.S.V.
6.4. DTFS × DTFT × DFT 187
112 t i t l e ( ’ S i n a l nã o p e r i ó d i c o ’ )
%
114 %s u b p l o t ( 2 , 3 , 4 )
subplot (3 ,2 ,2)
116 stem ( k , xkp , ’ k ’ )
ylabel ( ’X p [ k ] ’ )
118 xlabel ( ’k ’ )
t i t l e ( ’DTFS de x p [ n ] ’ )
120 v = axis ;
v ( 1 ) = min ( k ) ;
122 v ( 2 ) = max( k ) ;
v ( 3 ) = min ( xkp ) ;
124 v ( 4 ) = max( xkp ) ;
axis (v)
126 %
%s u b p l o t ( 2 , 3 , 5 )
128 subplot (3 ,2 ,4)
p l o t (W,xW, ’ k ’ )
130 y l a b e l ( ’X( e ˆ{ j \Omega} ) ’ )
x l a b e l ( ’ \Omega ’ )
132 t i t l e ( ’DTFT de x [ n ] ’ )
v = axis ;
134 v ( 1 ) = min (W) ;
v ( 2 ) = max(W) ;
136 v ( 3 ) = min (xW) ;
v ( 4 ) = max(xW) ;
138 axis (v)
%
140 %s u b p l o t ( 2 , 3 , 6 )
subplot (3 ,2 ,6)
142 stem ( k , xk , ’ k ’ )
y l a b e l ( ’X [ k ] ’ )
144 xlabel ( ’k ’ )
t i t l e ( ’ N p−p o i n t DFT de x [ n ] ’ )
146 v = axis ;
v ( 1 ) = min ( k ) ;
148 v ( 2 ) = max( k ) ;
v ( 3 ) = min ( xk ) ;
150 v ( 4 ) = max( xk ) ;
axis (v)
152
154 %%%%%%%%%%%%%%%%%%%%%%%
156
%%
158 %% Para c o n f e r i r o r e s u l t a d o da equacao
%% com o r e s u l t a d o da f u n c a o f f t ( . )
160 %%
%f g = f f t ( xp ( 1 : 2 0 ) ) ;
162 %%
%f i g u r e ( 2 )
164 %stem ( 0 : 1 9 , ( a b s ( f g ) . * r e a l ( exp ( j * a n g l e ( f g ) ) ) ) )
%y l a b e l ( ’X [ k ] ’ )
166 %x l a b e l ( ’ k ’ )
% t i t l e ( ’ N p−p o i n t DFT de x [ n ] , c a l c u l a d a p e l a fun ç ão f f t ( x ) ’ )
168 %a x i s ( v )
%%
170
TET / UFF
188 Capı́tulo 6. Sinais no domı́nio da frequência
172 %%%%%%%%%%%%%%%%%%%%%%%
174
%
176 % EOF
%
A.S.V.
6.5. DTFT × DFT 189
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DTFT i n t e r p o l a t e d from DFT %
11 % Author : A l e x a n d r e S . de l a Vega %
% Version : /2010 1 2 1 4 / %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
15
17 % c l e a r wo rkspa ce
clear all
19 c l o s e a l l
21
% define input sequence
23 x b a s = rand ( 1 , 1 0 ) ;
N = length ( x bas ) ;
25
27 % c a l c u l a t e DTFS c o e f i c i e n t s
a = z e r o s ( 1 ,N ) ;
29 f o r k = 0 : ( N−1)
i n d = k+1;
31 f o r n = 0 : ( N−1)
a ( i n d ) = a ( i n d ) + ( x b a s ( n+1) * exp(− j * k * ( ( 2 * p i ) /N) * n ) ) ;
33 end
end
35 a mod = abs ( a ) ;
a d eg = ( a n g l e ( a ) * 1 8 0 ) / p i ;
37
39 % c a l c u l a t e DFT c o e f i c i e n t s
X k = f f t ( x bas ,N ) ;
41 X k mod = abs ( X k ) ;
X k deg = ( a n g l e ( X k ) * 1 8 0 ) / p i ;
43
45 % c a l c u l a t e DTFT i n t e r p o l a t i o n
m = 0:199;
47 M = l e n g t h (m) ;
Omega step = ( 2 * p i ) /M;
49 Omega = Omega step . * m;
51 X omega = z e r o s ( 1 ,M) ;
f o r k = 0 : ( N−1)
TET / UFF
190 Capı́tulo 6. Sinais no domı́nio da frequência
53 s i n r a t i o p a r a m = ( (N* Omega) − ( k * 2 * p i ) ) / 2 ;
s i n r a t i o = s i n ( s i n r a t i o p a r a m ) . / s i n ( s i n r a t i o p a r a m /N ) ;
55 X p a r t i a l = a ( k+1) . * s i n r a t i o . * ...
exp(− j . * ( Omega−(k * ( ( 2 * p i ) /N ) ) ) . * ( ( N− 1 ) / 2 ) ) ;
57 X omega = X omega + X p a r t i a l ;
end
59 X omega = X omega / N;
65 % draw s e q u e n c e s
figure (1)
67
n = 0 : ( N−1);
69 k = 0 : ( N−1);
71 subplot (4 ,2 ,1)
stem ( n , x b a s )
73 ylabel ( ’x [n] ’ )
xlabel ( ’n ’ )
75 t i t l e ( ’ Representation of a nonperiodic signal (x [ n ] ) :
Time ( n ) X Frequency ( k ) ’ )
77
%x p e r = [ x b a s x b a s x b a s ] ;
79 %n p e r = 0 : ( l e n g t h ( x p e r ) −1);
%s u b p l o t ( 4 , 2 , 2 )
81 %stem ( n per , x p e r )
%y l a b e l ( ’ x { p e r } [ n ] ’ )
83 %x l a b e l ( ’ n ’ )
85 subplot (4 ,2 ,3)
stem ( k , a mod , ’ r ’ )
87 y l a b e l ( ’ | a {k} | ’ )
xlabel ( ’k ’ )
89 t i t l e ( ’DFT r e p r e s e n t a t i o n o f a p e r i o d i c e x t e n s i o n ( \ D e l t a k = 2 * \ p i / N) ’ )
91 subplot (4 ,2 ,4)
stem ( k , a deg , ’ r ’ )
93 y l a b e l ( ’ \ a n g l e a {k} ( d e g r e e ) ’ )
xlabel ( ’k ’ )
95
subplot (4 ,2 ,5)
97 stem ( k , X k mod , ’ r ’ )
y l a b e l ( ’ | X {k} | ’ )
99 xlabel ( ’k ’ )
t i t l e ( ’FFT r e p r e s e n t a t i o n o f a p e r i o d i c e x t e n s i o n ( \ D e l t a k = 2 * \ p i / N) ’ )
101
subplot (4 ,2 ,6)
103 stem ( k , X k deg , ’ r ’ )
y l a b e l ( ’ \ a n g l e X {k} ( d e g r e e ) ’ )
105 xlabel ( ’k ’ )
A.S.V.
6.5. DTFT × DFT 191
x l a b e l ( ’Omega ( rad ) ’ )
113 t i t l e ( ’ I n t e r p o l a t e d DTFT from t h e DFT r e p r e s e n t a t i o n ( \ D e l t a k = 2 * \ p i / N) ’ )
AV = a x i s ;
115 a x i s ( [AV( 1 ) ( 2 * p i ) AV( 3 ) AV( 4 ) ] )
127 %
% EOF
129 %
TET / UFF
192 Capı́tulo 6. Sinais no domı́nio da frequência
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % T i t u l o : Demo de DFT de s e q u e n c i a s e n o i d a l %
% %
13 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Data : / 01/07/2 k9 / 2010 1 2 1 4 / %
15 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 %
19
% Limpeza do a mbiente
21 clear all
close all
23
25 % Parametros da s e q u e n c i a s e n o i d a l o r i g i n a l
A0 = 2 ;
27 F0 = 1 0 0 ;
T0 = 1/F0 ;
29 P0 = 0 ;
31
% Parametros da amostragem
33 SamplingFactor = 1 2 8 ; % Numero de p o n t o s por p e r i o d o
Fs = ( SamplingFactor * F0 ) ; % Sampling f r e q u e n c y
35 Ts = 1/ Fs ;
37 Nper = 4 ;
Nppp = (T0/Ts ) ; % Numero de p o n t o s por p e r i o d o
39 Ntot = ( Nper * Nppp ) ; % T o t a l de p o n t o s amostrados
41
% Montagem da s e q u e n c i a amostrada
43 n = 0 : ( Ntot −1);
x = A0 * c o s ( ( 2 * p i * F0 * ( n * Ts ) ) + P0 ) ;
45
47 % C a l c u l o da DFT sem l e a k a g e
NPfft = Ntot ; % Numero de p o n t o s da DFT sem l e a k a g e
49 k = 0 : ( NPfft −1);
51 X = f f t ( x , NPfft ) ;
53 Xmod = abs (X ) ;
A.S.V.
6.6. DFT × Leakage ou Smearing 193
Xang rad = a n g l e (X ) ;
55 Xang deg = Xang rad * 180/ p i ;
57
% C a l c u l o da DFT com l e a k a g e , d e v i d o a nao casamento de p e r i o d o s
59 N P f f t l p = Ntot * ( ( 2 * Nper ) −1)/(2 * Nper ) ; % Numero de p o n t o s da DFT com l e a k a g e
k l p = 0 : ( N P f f t l p −1);
61
Xlp = f f t ( x , N P f f t l p ) ;
63
Xlpmod = abs ( Xlp ) ;
65 Xlpang rad = a n g l e ( Xlp ) ;
Xlpang deg = Xlpang rad * 180/ p i ;
67
69 % C a l c u l o da DFT com l e a k a g e , d e v i d o a i n s e r c a o de z e r o s
N P f f t l = 3 * Ntot ; % Numero de p o n t o s da DFT com l e a k a g e
71
n l = 0 : ( N P f f t l −1);
73 ZeroPaddingVector = z e r o s ( 1 , ( N P f f t l −NPfft ) ) ;
x l = [ x , ZeroPaddingVector ] ;
75
k l = 0 : ( N P f f t l −1);
77 Xl = f f t ( x , N P f f t l ) ;
79 Xlmod = abs ( Xl ) ;
Xlang rad = a n g l e ( Xl ) ;
81 Xlang deg = Xlang rad * 180/ p i ;
83
%
85 % G r a f i c o s
%
87
% G r a f i c o da DFT com l e a k a g e , d e v i d o a i n s e r c a o de z e r o s
89 f i g u r e ( 1 )
91 subplot (2 ,2 ,1)
stem ( n , x )
93 t i t l e ( ’ S i n a l o r i g i n a l : x [ n ] = A 0 c o s ( 2 \ piF 0nT s + \ p h i 0 ) ’ )
xlabel ( ’n ’ )
95 y l a b e l ( ’ x [ n ] ’ )
AV = a x i s ;
97 a x i s ( [AV( 1 ) NPfft AV( 3 ) AV( 4 ) ] )
99 subplot (2 ,2 ,2)
stem ( k , Xmod)
101 t i t l e ( ’Mó d u l o da DFT de x [ n ] ’ )
xlabel ( ’k ’ )
103 y l a b e l ( ’ | X[ k ] | ’ )
AV = a x i s ;
105 a x i s ( [AV( 1 ) NPfft AV( 3 ) AV( 4 ) ] )
TET / UFF
194 Capı́tulo 6. Sinais no domı́nio da frequência
115
% G r a f i c o da DFT com l e a k a g e , d e v i d o a nao casamento de p e r i o d o s
117 figure (2)
143
% G r a f i c o da DFT com l e a k a g e , d e v i d o a i n s e r c a o de z e r o s
145 figure (3)
A.S.V.
6.6. DFT × Leakage ou Smearing 195
171 %
% EOF
173 %
TET / UFF
196 Capı́tulo 6. Sinais no domı́nio da frequência
• O Código 6.7 ilustra o cálculo das N-DFTs de duas sequências reais através do cálculo da
N-DFT de uma sequência complexa.
• O Código 6.8 ilustra o cálculo da 2N-DFT de uma sequência real através do cálculo da
N-DFT de uma sequência complexa.
Código 6.6: Cálculo das N-DFTs de duas sequências reais através do cálculo da N-DFT de uma
sequência complexa.
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
3 % Arquivo : c s f f t .m
%
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
7 f u n c t i o n [ Gk , Hk ] = c s f f t ( g , h )
9 %
% CS FFT Complex s e q u e n c e FFT
11 % CS FFT( g , h ) r e t u r n s G[ k ] and H[ k ] by u s i n g
% a s i n g l e FFT o p e r a t i o n .
13 %
15 x = g + ( j *h ) ;
17 X fft = f f t (x );
19 X aux = [ X f f t , X f f t ( 1 ) ] ;
X f f t c o n j r e f l c i r c = c o n j ( f l i p l r ( X aux ( 2 : end ) ) ) ;
21
Gk = ( X f f t + X f f t c o n j r e f l c i r c ) / ( 2 ) ;
23 Hk = ( X f f t − X f f t c o n j r e f l c i r c ) / ( 2 * j ) ;
25 end
27 %
% EOF
29 %
Código 6.7: Exemplo de cálculo das N-DFTs de duas sequências reais através do cálculo da
N-DFT de uma sequência complexa.
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
3 % Arquivo : t w o s e q s c o m p l e x f f t .m
%
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A.S.V.
6.7. Aceleração do cálculo da DFT 197
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % T i t u l o : C a l c u l o de FFT %
% de uma s e q u e n c i a complexa , %
13 % formada por duas s e q u e n c i a s r e a i s %
% distintas : x[n] = g [n] + j h[n] %
15 % %
% Autor : A l e x a n d r e S a n t o s de l a Vega %
17 % Data : / 2011 1 1 2 4 / %
% %
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
21
23 % l i m p e z a do ambiente de t r a b a l h o
% variaveis
25 c l e a r a l l
% janelas
27 c l o s e a l l
29
% d e f i n i c a o dos p ar amet ro s
31 N = 4 0 ;
n = 0 : ( N−1);
33
% d e f i n i c a o das s e q u e n c i a s de e n t r a d a
35 g = z e r o s ( 1 ,N ) ;
g (1:7) = 1;
37
h = z e r o s ( 1 ,N ) ;
39 h ( 1 : 1 1 ) = 1 ;
41
% c a l c u l o das FFTs i s o l a d a m e n t e
43 tic
%
45 G f f t = f f t ( g ) ;
H fft = f f t (h ) ;
47 %
t 2 r f f t = toc ;
49
59 %%%%%%%%%%%%%%%%%%%%%%%
61
% ilustra resultados
63
%AXIS ( [XMIN XMAX YMIN YMAX] )
65
TET / UFF
198 Capı́tulo 6. Sinais no domı́nio da frequência
figure (1)
67 %
subplot (4 ,2 ,1)
69 stem ( n , abs ( G f f t ) , ’ k ’ )
y l a b e l ( ’ |G[ k ] | ’ )
71 t i t l e ( ’Mó d u l o s c a l c u l a d o s por duas N−FFTs de sequ ê n c i a s r e a i s ’ )
%
73 s u b p l o t ( 4 , 2 , 2 )
stem ( n , a n g l e ( G f f t ) , ’ k ’ )
75 y l a b e l ( ’ \ a n g l e G[ k ] ’ )
t i t l e ( ’ Ân g u l o s de f a s e c a l c u l a d o s por duas N−FFTs de sequ ê n c i a s r e a i s ’ )
77 %
subplot (4 ,2 ,3)
79 stem ( n , abs ( H f f t ) , ’ k ’ )
y l a b e l ( ’ |H[ k ] | ’ )
81 %
subplot (4 ,2 ,4)
83 stem ( n , a n g l e ( H f f t ) , ’ k ’ )
y l a b e l ( ’ \ a n g l e H[ k ] ’ )
85 %
subplot (4 ,2 ,5)
87 stem ( n , abs ( G c s f f t ) , ’ r ’ )
y l a b e l ( ’ |G[ k ] | ’ )
89 t i t l e ( ’Mó d u l o s c a l c u l a d o s por uma N−FFT de sequ ê n c i a complexa ’ )
%
91 s u b p l o t ( 4 , 2 , 6 )
stem ( n , a n g l e ( G c s f f t ) , ’ r ’ )
93 y l a b e l ( ’ \ a n g l e G[ k ] ’ )
t i t l e ( ’ Ân g u l o s de f a s e c a l c u l a d o s por uma N−FFT de sequ ê n c i a complexa ’ )
95 %
subplot (4 ,2 ,7)
97 stem ( n , abs ( H c s f f t ) , ’ r ’ )
y l a b e l ( ’ |H[ k ] | ’ )
99 x l a b e l ( ’ k ’ )
%
101 s u b p l o t ( 4 , 2 , 8 )
stem ( n , a n g l e ( H f f t ) , ’ r ’ )
103 y l a b e l ( ’ \ a n g l e H[ k ] ’ )
xlabel ( ’k ’ )
105
A.S.V.
6.7. Aceleração do cálculo da DFT 199
stem ( n , abs ( H f f t ) , ’ k ’ )
125 h o l d on
stem ( n , abs ( H c s f f t ) , ’ r ’ )
127 y l a b e l ( ’ |H[ k ] | ’ )
xlabel ( ’k ’ )
129 %
subplot (2 ,2 ,4)
131 stem ( n , a n g l e ( H f f t ) , ’ k ’ )
h o l d on
133 stem ( n , a n g l e ( H c s f f t ) , ’ r ’ )
y l a b e l ( ’ \ a n g l e H[ k ] ’ )
135 xlabel ( ’k ’ )
137
%%%%%%%%%%%%%%%%%%%%%%%
139
141 %
% EOF
143 %
Código 6.8: Exemplo de cálculo da 2N-DFT de uma sequência real através do cálculo da N-DFT
de uma sequência complexa.
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
3 % Arquivo : o n e s e q c o m p l e x f f t .m
%
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % T i t u l o : C a l c u l o de FFT %
% de uma s e q u e n c i a complexa , %
13 % formada por duas s e q u e n c i a s r e a i s %
% p r o v e n i e n t e s de uma s e q u e n c i a : %
15 % x [n] = g [n] + j h[n] %
% g [n ] = v [2n ] %
17 % h [ n ] = v [ 2 n+1] %
% %
19 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Data : / 2011 1 1 2 4 / %
21 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23 %
25
% l i m p e z a do ambiente de t r a b a l h o
27 % v a r i a v e i s
clear all
29 % j a n e l a s
close all
31
33 % d e f i n i c a o dos p ar amet ro s
TET / UFF
200 Capı́tulo 6. Sinais no domı́nio da frequência
M = 40;
35 m = 0 : (M−1);
ind m = (m + 1 ) ;
37 m par = ( 2 *m) ;
m impar = ( 2 *m) + 1 ;
39 ind m par = m par + 1;
ind m impar = m impar + 1 ;
41 %
N = 2 *M;
43 n = 0 : ( N−1);
45
% d e f i n i c a o da s e q u e n c i a de e n t r a d a
47 v = z e r o s ( 1 ,N ) ;
v (1:11) = 1;
49
% c a l c u l o da FFT i s o l a d a m e n t e
51 tic
%
53 V f f t = f f t ( v ) ;
%
55 t 2 r f f t = t o c ;
57
% c a l c u l o da FFT com s e q u e n c i a complexa
59 tic
%
61 g = v ( ind m par ) ;
h = v ( ind m impar ) ;
63 %
[ G cs fft , H cs fft ] = c s f f t (g , h );
65 %
V c s f f t ( ind m ) = G c s f f t + ( exp(− j * ( p i /M) *m) .* H cs fft );
67 V c s f f t ( ind m + M) = G c s f f t + ( exp(− j * ( p i /M) * (m+M) ) . * H c s f f t ) ;
%
69 t 1 c f f t = toc ;
71
%%%%%%%%%%%%%%%%%%%%%%%
73
75 % i l u s t r a r e s u l t a d o s
79 figure (1)
%
81 subplot (3 ,2 ,1)
stem ( n , abs ( V f f t ) , ’ k ’ )
83 y l a b e l ( ’ |V[ k ] | ’ )
t i t l e ( ’Mó d u l o c a l c u l a d o por uma 2N−FFT de sequ ê n c i a r e a l ’ )
85 %
subplot (3 ,2 ,2)
87 stem ( n , a n g l e ( V f f t ) , ’ k ’ )
y l a b e l ( ’ \ a n g l e V[ k ] ’ )
89 t i t l e ( ’ Ân g u l o de f a s e c a l c u l a d o por uma 2N−FFT de sequ ê n c i a r e a l ’ )
%
91 subplot (3 ,2 ,3)
stem ( n , abs ( V c s f f t ) , ’ r ’ )
A.S.V.
6.7. Aceleração do cálculo da DFT 201
93 y l a b e l ( ’ |V[ k ] | ’ )
t i t l e ( ’Mó d u l o c a l c u l a d o por uma N−FFT de sequ ê n c i a complexa ’ )
95 %
subplot (3 ,2 ,4)
97 stem ( n , a n g l e ( V c s f f t ) , ’ r ’ )
y l a b e l ( ’ \ a n g l e V[ k ] ’ )
99 t i t l e ( ’ Ân g u l o de f a s e c a l c u l a d o por uma N−FFT de sequ ê n c i a complexa ’ )
%
101 subplot (3 ,2 ,5)
stem ( n , abs ( V f f t ) , ’ k ’ )
103 h o l d on
stem ( n , abs ( V c s f f t ) , ’ r ’ )
105 y l a b e l ( ’ |V[ k ] | ’ )
t i t l e ( ’ Compara ç ã o dos mó d u l o s ’ )
107 xlabel ( ’k ’ )
%
109 subplot (3 ,2 ,6)
stem ( n , a n g l e ( V f f t ) , ’ k ’ )
111 h o l d on
stem ( n , a n g l e ( V c s f f t ) , ’ r ’ )
113 y l a b e l ( ’ \ a n g l e V[ k ] ’ )
t i t l e ( ’ Compara ç ã o dos â n g u l o s de f a s e ’ )
115 xlabel ( ’k ’ )
117
%%%%%%%%%%%%%%%%%%%%%%%
119
121 %
% EOF
123 %
TET / UFF
202 Capı́tulo 6. Sinais no domı́nio da frequência
6.7.2 FFT
• O Código 6.9 ilustra a comparação entre o número de operações da DFT e de um tipo de
FFT.
7
%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
11 % T i t u l o : Comparacao do numero de o p e r a c o e s %
% entre %
13 % DFT por equacao o r i g i n a l %
% e %
15 % FFT implementada no s i m u l a d o r %
% %
17 % Autor : A l e x a n d r e S a n t o s de l a Vega %
% Data : / 2011 1 1 1 7 / %
19 % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21 %
23
% l i m p e z a do ambien te de t r a b a l h o
25 % v a r i a v e i s
clear all
27 % j a n e l a s
close all
29
A.S.V.
6.7. Aceleração do cálculo da DFT 203
53 % c a l c u l o da a c e l e r a c a o
mc = mc dft . / m c f f t ;
55 ac = a c d f t . / a c f f t ;
%
57 mcp = mc(Np ) ;
acp = ac (Np ) ;
59
61 %%%%%%%%%%%%%%%%%%%%%%%
63
% ilustra resultados
65 figure (1)
%
67 %AXIS ( [XMIN XMAX YMIN YMAX] )
m a x m c a c f f t = c e i l (max(max( m c f f t ) , max( a c f f t ) ) ) ;
69 %
subplot (4 ,2 ,1)
71 stem (Np , mcp dft , ’ k ’ )
h o l d on
73 p l o t (N, mc dft , ’ k ’ )
y l a b e l ( ’Nˆ2 ’ )
75 t i t l e ( ’ Number o f complex m u l t i p l i c a t i o n s : DFT ’ )
%
77 subplot (4 ,2 ,2)
stem (Np , a c p d f t , ’ k ’ )
79 h o l d on
p l o t (N, a c d f t , ’ k ’ )
81 y l a b e l ( ’N(N−1) ’ )
t i t l e ( ’ Number o f complex a d d i t i o n s : DFT ’ )
83 %
subplot (4 ,2 ,3)
85 stem (Np , m c p f f t , ’ r ’ )
h o l d on
87 p l o t (N, m c f f t , ’ r ’ )
v = AXIS ;
89 v (4) = max mc ac fft ;
AXIS ( v )
91 y l a b e l ( ’N/2 l o g 2 (N) ’ )
t i t l e ( ’ Number o f complex m u l t i p l i c a t i o n s : FFT ’ )
93 %
subplot (4 ,2 ,4)
95 stem (Np , a c p f f t , ’ r ’ )
h o l d on
97 p l o t (N, a c f f t , ’ r ’ )
v = AXIS ;
99 v (4) = max mc ac fft ;
AXIS ( v )
101 y l a b e l ( ’N l o g 2 (N) ’ )
t i t l e ( ’ Number o f complex a d d i t i o n s : FFT ’ )
103 %
subplot (4 ,2 ,5)
105 stem (Np , mcp dft , ’ k ’ )
h o l d on
107 p l o t (N, mc dft , ’ k ’ )
%
109 stem (Np , m c p f f t , ’ r ’ )
p l o t (N, m c f f t , ’ r ’ )
111 t i t l e ( ’ Number o f complex m u l t i p l i c a t i o n s : DFT and FFT ’ )
TET / UFF
204 Capı́tulo 6. Sinais no domı́nio da frequência
%
113 subplot (4 ,2 ,6)
stem (Np , a c p d f t , ’ k ’ )
115 h o l d on
p l o t (N, a c d f t , ’ k ’ )
117 %
stem (Np , a c p f f t , ’ r ’ )
119 p l o t (N, a c f f t , ’ r ’ )
t i t l e ( ’ Number o f complex a d d i t i o n s : DFT and FFT ’ )
121 %
subplot (4 ,2 ,7)
123 stem (Np , mcp , ’ b ’ )
h o l d on
125 p l o t (N, mc , ’ b ’ )
t i t l e ( ’ Number−of −complex−m u l t i p l i c a t i o n s g a i n ’ )
127 x l a b e l ( ’N ’ )
%
129 subplot (4 ,2 ,8)
stem (Np , acp , ’ b ’ )
131 h o l d on
p l o t (N, ac , ’ b ’ )
133 t i t l e ( ’ Number−of −complex−a d d i t i o n s g a i n ’ )
x l a b e l ( ’N ’ )
135
137 %%%%%%%%%%%%%%%%%%%%%%%
139
%
141 % EOF
%
A.S.V.
Referências bibliográficas
[Ant86] A. Antoniou. Digital Filters: Analysis and Design. Tata McGraw-Hill, New Delhi,
India, 2nd reprint edition, 1986.
[Cad73] J. A. Cadzow. Discrete-Time Systems: An Introduction with Interdisciplinary Ap-
plications. Prentice-Hall, Englewood Cliffs, NJ, 1973.
[DdSN10] P. S. R. Diniz, E. A. B. da Silva, and S. Lima Netto. Digital Signal Processing:
System Analysis and Design. Cambridge University Press, Cambridge, UK, 2nd
edition, 2010.
[Jac96] L. B. Jackson. Digital Filters and Signal Processing - with MATLAB exercises.
Kluwer Academic Publishers, 3rd edition, 1996.
[KD04] H. Kopka and P. W. Daly. A Guide to LATEX and Electronic Publishing. Addison-
Wesley, Harlow, England, 4th edition, 2004.
[MG04] F. Mittelbach and M. Goosens. The LATEX Companion. Addison-Wesley, Boston,
MA, USA, 2th edition, 2004.
[Mit98] S. K. Mitra. Digital Signal Processing: A Computer-Based Approach. McGraw-Hill,
New York, NY, 1998.
[OS75] A. V. Oppenheim and R. W. Schafer. Digital Signal Processing. Prentice-Hall,
Englewood Cliffs, NJ, 1975.
[OWY83] A. V. Oppenheim, A. S. Willsky, and I. T. Young. Signals and Systems. Prentice-
Hall, Englewood Cliffs, NJ, 1983.
[PL76] A. Peled and B. Liu. Digital Signal Processing: Theory, Design and Implementation.
John Wiley, New York, NY, 1976.
[PM06] J. G. Proakis and D. G. Manolakis. Digital Signal Processing: Principles, Algorithms
and Applications. Prentice Hall, 4th edition, 2006.
[Rob09] M. J. Roberts. Fundamentos em Sinais e Sistemas. McGraw-Hill, São Paulo, SP,
2009.
[SDD84] W. D. Stanley, G. R. Dougherty, and R. Dougherty. Signals and Systems. Prentice-
Hall, Reston, Virginia, 2nd edition, 1984.
[She95] K. Shenoi. Digital Signal Processing in Telecommunications. Prentice-Hall PTR,
Upper Saddle River, NJ, 1995.
[SK89] R. D. Strum and D. E. Kirk. First Principles of Discrete Systems and Digital Signal
Processing. Addison-Wesley, Massachusetts, 1989.
205