i have compared the result with inbuilt matlab function for averaging.
and the code is developed according to the basic concept of averaging filter.
so i didn't find any fault or error although the result was quite nice.
if you have made a code in your own logic then i will be happy to see it.
I do not think that "round(median())" matches "without using built-in functions.
The brute clearing header "clc; clear all; close all;" removes all functions from the memory, such that reloading wastes much time, and all breakpoints of the debugger are clear also. But it is a really bad idea to prevent debugging conceptionally.
Using "sum" as name of a variable leads to errors frequently, when the user wants to use the function with the same name. Therefore it is recommended not to shadow built-in functions.
It would be much more useful for others, if the code is written as a function and the parameters and data are provided as input arguments. Using INPUT in a script is not convenient and not usable in productive code. Using "ans" to provide a result is a bad idea, because this is overwritten by the last not caught output of any function. Therefore the result can change unexpectedly during debugging.
For educational purposes, applying Matlab's vectorized methods would be much more valuable and substantially faster. Without a documentation and any comments in the code, modifications demands for guessing what the code should achieve.
My conclusion: This is neither useful nor usable in productive code, nor helpful for eductaional purposes.