Changed ~ to extension to fix issue with R2009a.