diff --git a/RemoveAllMEXFiles.m b/RemoveAllMEXFiles.m
new file mode 100644
index 0000000000000000000000000000000000000000..084bcfaf371299530b6868517f0b157393b97d13
--- /dev/null
+++ b/RemoveAllMEXFiles.m
@@ -0,0 +1,23 @@
+function [] = RemoveAllMEXFiles(ignoreWarning)
+% Removes all mexfiles in current folder and all subfolders
+
+
+files = dir('./**/*.mex*');
+
+if nargin <1 || ~ignoreWarning
+    disp('WARNING!!!!')
+    disp('This will delete ALL files that contains "mex". ')
+    disp('This could potentially remove files from necessary toolboxes.')
+    disp('The following files will be deleted:')
+    for n = 1:length(files)
+        disp([files(n).folder '/' files(n).name])
+    end
+    choice  = input('Do you want to continue? \n(y/n)  ','s');
+end
+if (nargin==1 && ignoreWarning) || strcmp(choice,'y')
+    clear mex
+    for n = 1:length(files)
+        delete([files(n).folder '/' files(n).name])
+    end 
+end
+