mmw Demo Data Structure v0.1:
#ADCsamples is set in the profileCfg line of the cfg file ;
#RangeBins = number of ADC samples rounded up(向上取整) to the nearest power of 2
profile.cfg : profileCfg 0 77 372 7 114.29 0 0 35 1 240 2257 0 0 30 ;
import math
# number of ADC samples
num_adc_samples = 240
# calculate RangeBins
range_bins = int(math.pow(2, math.ceil(math.log2(num_adc_samples))))
"""math.pow(2, 3) = 2**3 #2的3次方
2** math.ceil(math.log2(num_adc_samples))
#這樣也可以 #2**8=256
使用math模塊中的pow、ceil和log2函數來計算RangeBins。
首先,我們使用math.log2函數來計算num_adc_samples的對數。
然後,我們使用math.ceil函數將其向上取整到最接近的整數。
最後,我們使用math.pow函數計算2的幾次方,以得到最終的RangeBins值。
"""
print("RangeBins:", range_bins)

推薦hahow線上學習python: https://igrape.net/30afN




![Python: 如何使用 os.environ[“PATH”] 設定環境變數?與 sys.path.append() 差別為何? Python: 如何使用 os.environ[“PATH”] 設定環境變數?與 sys.path.append() 差別為何?](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2024/09/20240905135312_0_890fa1.png?quality=90&zoom=2&ssl=1&resize=350%2C233)





近期留言