Condition: unsuccessful userpath
with addpath
and savepath
Differential conditions: unable to start Matlab as sudo/root here
Support: MATLAB is not intended to be run by the super user - Service desk.
Settings
echo "export MATLAB_USE_USERWORK=1" >> $HOME/.bashrc
matlab -nodesktop -nosplash -r \
"userpath('/home/masi/Documents/bin/matlab/'); exit;"
Situations which cause userpath
to be empty (''
)
Test code 1
userpath('/home/masi/Documents/bin/matlab/') home='/home/masi/'; savepath(fullfile(home, 'pathdef.m')); % ~/pathdef.m originally but reject because expansion of ~ not working userpath
Output
''
Expected output
'/home/masi/Documents/bin/matlab/:'
Complete reiteration from Matlab's prompt after starting Matlab
>> userpath ans = /home/masi/Documents/bin/matlab/: >> home='/home/masi/'; >> savepath(fullfile(home, 'pathdef.m')); >> userpath ans = ''
Test code 2
if (userpath == '') userpath('/home/masi/Documents/bin/matlab/') addpath('/home/masi/Documents/Math/') savepath '/home/masi/pathdef.m' end % Visualising path in Home > Environment > Set Path
Output:
/home/masi/Documents/Math/
stays in path, but/home/masi/Documents/bin/matlab/
not. Expected output: both stay in path.Test code 3
% Edit the Matlab preference file as root. [Kusalananda] % My startup.m userpath('/home/masi/Documents/bin/matlab/') addpath('/home/masi/Documents/Math/') savepath '/home/masi/startup.m' % Visualising path in Home > Environment > Set Path
Output:
/home/masi/Documents/Math/
stays in path, but/home/masi/Documents/bin/matlab/
not. Expected output: both stay in path.Test code 4
% Use MATLABPATH environment variable instead. [Kusalananda]
How?
Matlab: 2016a
System: Linux Ubuntu 16.04 64 bit
Hardware: Macbook Air 2013-mid
Related: setup wfdb in Linux here where the official script is incomplete