this和that的区别和原理

微信小程序开发交流qq群   173683895

   承接微信小程序开发。扫码加微信。

正文:

本篇博文纯属个人见解,如有不妥,可以留言批评指正,谢谢。

var that =this;

this指的是当前的对象。 that是一个临时的变量,用于保存当前对象的this状态。(that可以随便取名)

示例:

Page({
  data: {
  },
  onLoad:function(){
    var that = this;
    this.a = 1;
    console.log(this.a)
    setTimeout(function () {
      console.log(this.a)
      console.log(that.a)
    }, 1000)
  }
})

打印结果是:

原理说明:(有3个log,我简称log1,log2,log3)

log1打印1,这里this指的是onLoad函数对象的a的值.

log2打印结果是undefined , 这里this指的是setTimeout里面的匿名函数对象,它是没有a的。

log3打印出1,这里that代表的是onLoad函数对象的a的值。

 

### ASK Modulation and Demodulation Principles In communication systems, Amplitude Shift Keying (ASK) represents one of the fundamental digital modulation techniques where data transmission occurs by varying the amplitude of a carrier wave. The binary information is encoded into changes between two predefined amplitudes. #### Encoding Binary Data with ASK For ASK modulation, when transmitting binary '0', no signal or a lower amplitude level might be sent; whereas for binary '1', a higher amplitude version of the carrier frequency gets transmitted. Mathematically speaking, if \( A \) denotes the amplitude and \( f_c \) stands for the carrier frequency, then: \[ s(t)=\left\{ \begin{array}{ll} 0 & ,\text{for bit } 0 \\ A\cos(2πf_ct+\phi) &, \text{for bit } 1 \end{array} \right. \] where \( \phi \) indicates phase shift which can often remain constant during simple implementations[^2]. #### Implementing Envelope Detection for Demodulation To recover the original message from an ASK-modulated signal requires demodulating the received Radio Frequency (RF) carrier. An envelope detector serves as perhaps the most straightforward method to achieve this goal. This type of circuit essentially follows the peaks of incoming signals allowing extraction of the underlying baseband waveform that carries actual information bits[^1]. The process involves rectifying the input RF signal through diodes followed by filtering out high-frequency components via capacitors leaving behind only low-frequency variations corresponding to the initial unmodulated sequence. ```python import numpy as np from scipy import signal def ask_modulate(bits, fc=1e6, fs=10e6): t = np.arange(len(bits)) / fs carrier = np.cos(2 * np.pi * fc * t) mod_signal = [] for b in bits: amp = 1 if b == 1 else 0 mod_signal.extend([amp * c for c in carrier]) return np.array(mod_signal) bits_sequence = [0, 1, 0, 1, 1, 0] ask_waveform = ask_modulate(bits_sequence) ```
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

a_靖

对你有帮助吗?打赏鼓励一下?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值