Bug of the day: if you use the save function inside a function, and one of the things you’re saving is an anonymous function, then all the variables in the scope of the (non-anonymous) function will be saved along in the .mat file. So for example:
function funtest X = randn(5000); a = @(x) x+1; save test a end
If you look at test.mat you will find that the file is > 150MB. However if you remove the X line it’s less than 1 KB. So X must be saved despite your instructions to the contrary.