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

15 次查看(过去 30 天)
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.

采纳的回答

Shuppar
Shuppar 2019-1-18
编辑:Shuppar 2019-1-18
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by