我被認爲是MATLAB的初學者。 我需要找到一些圖形的FWHM,這些圖形在峯值時相當嘈雜且不一致。 下面是我的基本代碼,在一些來自stackoverflow用戶的代碼的幫助下。如何找到噪聲圖的平均值以獲得FWHM?
DD11=dicomrt_read3ddose(1,'waterphantom50x1mm15x1cmslabs500Mill_2.5cmFS_20cmx20cmDE.3ddose');
%plot first function
a=squeeze(DD11(100,:,55));
figure;
plot(a);
hold on;
%find half of maximum value
max(a);
halfAmax=0.5*(max(a));
%plot straight line across the first function
x2=[1:1:200];
LineValue=halfAmax;
plot(x2,LineValue);
%Find the starting indices of those segments of consecutive points that exceed LineValue
idx = find(diff(a >= LineValue))
hold on;
x3 = x2(idx) + (LineValue - a(idx)) .* (x2(idx+1) - x2(idx)) ./ (a(idx+1) - a(idx))
plot(x3, LineValue, 'go', [x2(1) x2(end)], LineValue*[1 1], 'k:');
%distance of the two points
fwhmwidth=[x3(end)-x3(1)].*0.1
hold on;
%plot first function
b=squeeze(DD11(100,:,7));
plot(b);
hold on;
%find half of maximum value
max(b);
halfAmax=0.5*(max(b));
%plot straight line across the first function
x2=[1:1:200];
LineValue=halfAmax;
plot(x2,LineValue);
%Find the starting indices of those segments of consecutive points that exceed LineValue
idx = find(diff(b >= LineValue))
hold on;
x3 = x2(idx) + (LineValue - b(idx)) .* (x2(idx+1) - x2(idx)) ./ (b(idx+1) - b(idx))
plot(x3, LineValue, 'go', [x2(1) x2(end)], LineValue*[1 1], 'k:');
%distance of the two points
fwhmwidth=[x3(end)-x3(1)].*0.1
我希望那個; (1)我可以找到這些峯值的平均值,因爲它們很嘈雜 (2)我可以更好地解釋我上面的代碼,如下所示;
%Find the starting indices of those segments of consecutive points that exceed LineValue
idx = find(diff(b >= LineValue))
hold on;
x3 = x2(idx) + (LineValue - b(idx)) .* (x2(idx+1) - x2(idx)) ./ (b(idx+1) - b(idx))
plot(x3, LineValue, 'go', [x2(1) x2(end)], LineValue*[1 1], 'k:');
非常感謝。