以下是用MATLAB计算输入参数的半峰全宽的代码:\n\nmatlab\n% 输入数据\nx = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\ny = [0, 0.1, 0.4, 0.8, 1, 0.8, 0.4, 0.1, 0, 0];\n\n% 找到峰值的位置\n[~, peakIndex] = max(y);\n\n% 找到半峰高度\nhalfHeight = y(peakIndex)/2;\n\n% 找到半峰全宽的左边界\nleftIndex = peakIndex;\nwhile y(leftIndex) > halfHeight\n leftIndex = leftIndex - 1;\nend\n\n% 找到半峰全宽的右边界\nrightIndex = peakIndex;\nwhile y(rightIndex) > halfHeight\n rightIndex = rightIndex + 1;\nend\n\n% 计算半峰全宽\nFWHM = x(rightIndex) - x(leftIndex);\n\n% 显示结果\ndisp(['半峰全宽为:', num2str(FWHM)]);\n\n\n请注意,这个代码只适用于输入数据为单峰的情况。如果数据有多个峰或者是峰形不规则的情况,需要进行适当的修改来适应不同的情况。


原文地址: https://www.cveoy.top/t/topic/pD8a 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录