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: matplotlib如何設定座標軸刻度? plt.xticks(seq, labels) ;如何生成fig, ax物件? fig = plt.figure(figsize= (10.24, 7.68)) ; ax = fig.add_subplot() ; fig, ax = plt.subplots(figsize=(10.24, 7.68)) ; 如何使用中文? plt.rcParams[“font.family”] = [“Microsoft JhengHei”] Python: matplotlib如何設定座標軸刻度? plt.xticks(seq, labels) ;如何生成fig, ax物件? fig = plt.figure(figsize= (10.24, 7.68)) ; ax = fig.add_subplot() ; fig, ax = plt.subplots(figsize=(10.24, 7.68)) ; 如何使用中文? plt.rcParams[“font.family”] = [“Microsoft JhengHei”]](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2023/02/20230209083006_41.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

近期留言