I used following script to obtain m file directory and to change current directory:
p = mfilename('fullpath');
s = find(p=='\');
filePath = p(1:s(end)-1);
s and filePath part is for obtaining the folder directory, not for m file address.
Then I used uigetdir(cd). It works on R2013b but not on R2011b. How can I overcome this situation for R2011b?