Thank you for your comment. Have you already looked through this code (see below)? Do you have questions about it? Here is the link to download this program: www.mathworks.com/matlabcentral/fileexchange/130639-data-analysis-spi-based-on-rainfall-data
Here's the video I did before this one discussing cleaning the data: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-BPXWsF3zkMw.html Have you checked this one out?