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: 如何將folder_name, file_name合併為file_path? fpath = os.path .join(folder, fname) ; “\\”.join([folder, fname]) ; 如何將file_path拆分出folder? Python: 如何將folder_name, file_name合併為file_path? fpath = os.path .join(folder, fname) ; “\\”.join([folder, fname]) ; 如何將file_path拆分出folder?](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2023/03/20230330132954_84.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

![Python常用的模組內建常數; __name__ ; __file__ ; __doc__ ; __all__ ;__dict__; vars()->Dict[str,str] ; dir()->List[str] Python常用的模組內建常數; __name__ ; __file__ ; __doc__ ; __all__ ;__dict__; vars()->Dict[str,str] ; dir()->List[str]](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2022/11/20221112184006_50.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言