Matlab 2015b, i open matlab associated file,but matlab current path does not update to where the file is in?

when i double click on xx.m file and start matlab2015b, its current folder is still the default path. how should i fix this problem?
in help doc:MATLAB Startup Folder,i find the following discription:
Default Folder on Windows Platforms:
Double-click a file type associated with MATLAB
The folder in which the file resides is the startup folder. The userpath folder is automatically added to the search path.
i checked my setting in "On the Home tab, in the Environment section, click Preferences. Select MATLAB > General. "
i think it ok to set: Location based on MATLAB startup rules.
moreover, i check the matlabrc.m and startup.m file, cd function works in following context:
if ispc,
pathToBin = [matlabroot,filesep,'bin',filesep,computer('arch')];
if isequal(pwd, pathToBin),
cd (matlabroot);
end;
end;
and
if ~(ismcc || isdeployed || feature('isdmlworker')) && usejava('jvm')
s = Settings;
switch s.matlab.workingfolder.InitialWorkingFolder
case 'last_folder'
% Last folder
loc = s.matlab.workingfolder.LastFolderPath;
case 'custom_folder'
% Specified folder
loc = s.matlab.workingfolder.CustomFolderPath;
otherwise
% no op in default folder, other random string
loc = '';
end
if(~isempty(loc))
if (exist(loc,'dir') == 7)
try
cd(loc)
catch exc
warning(message('MATLAB:matlabrc:InitialWorkingFolderPermission', pwd));
end
else
warning(message('MATLAB:matlabrc:InitialWorkingFolder', pwd));
end
end
end
is there anyone who knows how matlab accomplished "The folder in which the file resides is the startup folder" ?

1 Comment

I do not know, how to solve this. In my opinion, starting an M-file by a double click in the file explorer of the operating system is a bad design at all, so I do not have this problem.

Sign in to comment.

Answers (0)

Categories

Products

Release

R2015b

Asked:

on 9 Jan 2019

Commented:

Jan
on 9 Jan 2019

Community Treasure Hunt

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

Start Hunting!