1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RでAM変調、復調

Last updated at Posted at 2016-07-13

概要

RでAM変調、復調やってみた。
復調は、直交復調です。

写真

iq.png

サンプルコード

par(mfrow = c(3, 1))
lpf <- function(i, samplerate, freq, x) {
	o <- (sin(2 * pi * 110 * x) + 0.5 * sin(2 * pi * 440 * x)) / 2
	q <- 1
	omega <- 2 * pi * freq / samplerate
	alpha <- sin(omega) / (2 * q)
	a0 <-  1 + alpha
	a1 <- -2 * cos(omega)
	a2 <-  1 - alpha
	b0 <- (1 - cos(omega)) / 2
	b1 <-  1 - cos(omega)
	b2 <- (1 - cos(omega)) / 2
	in2 <- 0
	in1 <- 0
	out2 <- 0
	out1 <- 0
	for (j in seq(length(i)))
	{
		o[j] <- b0 / a0 * i[j] + b1 / a0 * in1 + b2 / a0 * in2 - a1 / a0 * out1 - a2 / a0 * out2
		in2 <- in1;
		in1 <- i[j];
		out2 <- out1;
		out1 <- o[j];
	}
	return(o)
}
N <- 10000
t <- 1:N / N
C <- 1
fc <- 30
A <- 0.7
fs <- 3
fl <- 20
cutoff <- 15
Vin <- sin(2 * pi * fs * t)
plot(Vin)
Vam <- (A * sin(2 * pi * fs * t) + C) * sin(2 * pi * fc * t)
plot(Vam)
Q <- Vam * cos(2 * pi * fl * t)
I <- Vam * sin(2 * pi * fl * t)
Q2 <- lpf(Q, N, cutoff, t)
I2 <- lpf(I, N, cutoff, t)
Vdm <- sqrt(Q2 * Q2 + I2 * I2)
Vout <- lpf(Vdm, N, 10, t)
plot(Vout)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?