Problema 3 (Gráficos com ggplot2)

Banda Passante

#install.packages("ggplot2")

library(ggplot2)

xt<-function(t){
                if (t==0){
                     return(1)
                         }else {
                              return((sin(100*t)/(100*t))*cos(100*pi*t) )
                             }
}

t1<-seq(-25,25,le=100) ; t2<-seq(-25,25,le=1000) ; t<-list(t1,t2)

x.t<-list() ; df<-list()

for (i in 1:length(t)){
  x.t[[i]]<-sapply(t[[i]],xt)

  df[[i]]<-data.frame(t[[i]],x.t)
}
## banda passante para 100 valores de t entre -25 e 25
ggplot(data=df[[1]], aes(x=t[[1]],y=x.t[[1]]))+
                                geom_line()

## banda passante para 100 valores de tempo entre -25 e 25
ggplot(data=df[[2]], aes(x=t[[2]],y=x.t[[2]]))+
                                geom_line()

Sinal Recebido

rt<-function(t){
          if (t==0){
            sinc<-1
          }else{
            sinc<-sin(100*t)/(100*t)
          }
  return(xt(t)+sinc*cos(150*pi*t))
}

t1<-seq(-25,25,le=100)  ; t2<-seq(-25,25,le=1000) 

t<-list(t1,t2) ; df<-list() ; r.t<-list()

for (i in 1:length(t)){

  r.t[[i]]<-sapply(t[[i]],rt)

  df[[i]]<-data.frame(t[[i]],r.t)

}
## Sinal Recebido para 100 valores de t entre -25 e 25
 ggplot(df[[1]],aes(t[[1]],r.t[[1]]))+
                     geom_line()

## Sinal Recebido para 1000 valores de t entre -25 e 25
 ggplot(df[[2]],aes(t[[2]],r.t[[2]]))+
                     geom_line()