MATLAB: A user-defined function while working with the matlab command prompt does not work from linux prompt!

linuc promptpathdef.muser defined function

I have added all my functions to pathdef.m and the script works just fine while I am on Matlab prompt. But when I try to run the same script usng linux prompt with matlab -r -nodesktop -nosplash it says undefined function or variable.

Best Answer

Alright, it was the location of pathdef.m... I don't know why is it working now, but I changed it from /home to /usr/local/MATLAB/R2015a/toolbox/local on my linux ... and it is working now. Matlab had been able to access pathdef.m from its own command prompt previously but not from the linux terminal. Anyhow the following helped Matlab access pathdef.m even from the linux command prompt:
1) Deleted pathdef.m from /home
2) Restored the path to default:
restoredefaultpath
rehash toolboxcache
savepath
3) Tried to add the folder with my functions to Matlab path. I clicked on the home icon on the setpath window and tried to save. I was denied the permission so closed the window and Matlab and re-opened them again with root permission and followed the same above steps. This time I was able to add the folder to the path and the file pathdef.m was saved in the folder which was selected after I clicked on the home icon. The location happens to be /usr/local/MATLAB/R2015a/toolbox/local on my linux.
Related Question