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: pandas.DataFrame([ ]) 與 pandas.DataFrame([[ ]]) 的差別? 如何為DataFrame增加首列? Python: pandas.DataFrame([ ]) 與 pandas.DataFrame([[ ]]) 的差別? 如何為DataFrame增加首列?](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2023/03/20230313160116_63.png?quality=90&zoom=2&ssl=1&resize=350%2C233)




![Python: 如何判斷字符串內容是否為數字(整數或浮點數)? isinstance( eval( entry.get() ), (float, int) ) ; str.isdigit() #不包括小數點和負號 ; try~ except ValueError~ ; 正則表示法 regular expression ; pattern = ‘^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$’ Python: 如何判斷字符串內容是否為數字(整數或浮點數)? isinstance( eval( entry.get() ), (float, int) ) ; str.isdigit() #不包括小數點和負號 ; try~ except ValueError~ ; 正則表示法 regular expression ; pattern = ‘^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$’](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2023/05/20230512152430_3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)




近期留言