Hello,
I wanted to clarify that there is no error with the "white" contour you get in the image attached by you. white contour represents the "beam spot" as defined by the "FWHM" (Full Width at Half Maximum) criterion. This contour includes all the points where the pressure is greater than half of the maximum pressure.
I understand you were expecting the contour indicated by the black line, but that does not correspond to the "beam spot" as defined by FWHM. However, there is a workaround to achieve your desired contour. You can define a new threshold, let us say, "threshold_desired_contour," and plot the contour for the points where the pressure exceeds this new threshold.
To implement this, you can add a few additional lines at the end of your existing code:
threshold=maxPressure*contour_size;
Desired_contourData = contourc(x_axis, y_axis, Pressure, [threshold threshold]);
ContourX = Desired_contourData(1,2:end);
ContourY = Desired_contourData(2,2:end);
Desired_spotSizeX = max(ContourX) - min(ContourX);
Desired_spotSizeY = max(ContourY) - min(ContourY);
fprintf('Focal Spot Size of the desired contour in X direction: %.2f mm\n', Desired_spotSizeX);
fprintf('Focal Spot Size of the desired contour in Y direction: %.2f mm\n', Desired_spotSizeY);
plot(ContourX, ContourY, 'k', 'LineWidth', 2);
legend({'Focal spot (FWHM)','desired Focal spot'},'Location','northeast');
The plot generated after adding above code:
The screen-shot of command window is attached below:
I hope this is as per your requirement !