MATLAB, a powerful software tool, is widely used in various engineering and scientific fields for…