怎么修改matlab的当前目录

我的matlab原来的默认的当前目录(current directory)是C:\Users\GDP\Documents\MATLAB,而我的matlab安装在E盘的matlab文件中,我想把当前目录改到E盘matlab中,就在其中建了一个文件夹,通过setpath添加到搜索路径中。
但是,我把当前目录改到我自建的文件后,重新打开又变成原来的,我就在setpath中把C:\Users\GDP\Documents\MATLAB给删了,结果当前目录就变成C:\Users\GDP\Desktop,怎么也改不了了,麻烦高手指点一下,谢谢!
你好,我按你说的改的,输入命令cd E:\matlab\work,当前目录是变成E:\matlab\work,但没有什么提示,并且重新运行matlab还是变成原来的当前目录。你能说详细点吗,谢谢!

方法/步骤:
  1、新建一个.txt文件文件
  2、在其中输入:cd H:\MatlabFiles
  其中“H:\MatlabFiles”为你要设置的路径。
  cd 为打开的意思。dos窗口经常用这个命令。
  注意:目录不要用中文。  
  3、将文件重新命名为startup.m
  4、将这个文件放入路径:
  C:\Program Files\MATLAB\R2011b\toolbox\local
  当然如果不是按照默认路径装的,前面的路径有所不同,但后面都应该是toolbox\local
  5、打开Matlab 就会发现,当前目录已经改变了。
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-10-06
这个是matlab的默认设置,改不了的,你把你的路径也弄在它的小窗口中,然后,启动后你的也在你里,点击下拉箭头,把你的路径一点就好了本回答被提问者采纳
第2个回答  2018-10-14
用cd命令或者手动设置只能在当前开启的matlab环境中有效,一旦matlab重启就不能了,只是2016a是这样的,之前的版本也是这样的,虽然改不了默认当前工作目录,但你可以把自己的文件夹添加到搜索路径中,虽然不现实需要自己点开但里面的文件也可以在命令窗口直接调用,的,不影响使用
第3个回答  2020-04-17
文件放在哪里,直接可以运行。不用change
folder,会把m文件位置变成当前工作目录。
%save
m-file
as
aa.m
function
res=aa()
clc
p1
=
mfilename('fullpath')
i=findstr(p1,'\')
p1=p1(1:i(end))
cd(p1)
end
mfilename
file
name
of
currently
running
function
syntax
mfilename
p
=
mfilename('fullpath')
c
=
mfilename('class')
description
mfilename
returns
a
string
containing
the
file
name
of
the
most
recently
invoked
function.
when
called
from
within
the
file,
it
returns
the
name
of
that
file.
this
allows
a
function
to
determine
its
name,
even
if
the
file
name
has
been
changed.
p
=
mfilename('fullpath')
returns
the
full
path
and
name
of
the
file
in
which
the
call
occurs,
not
including
the
filename
extension.
c
=
mfilename('class')
in
a
method,
returns
the
class
of
the
method,
not
including
the
leading
@
sign.
if
called
from
a
nonmethod,
it
yields
the
empty
string.
tips
if
mfilename
is
called
with
any
argument
other
than
the
above
two,
it
behaves
as
if
it
were
called
with
no
argument.
when
called
from
the
command
line,
mfilename
returns
an
empty
string.
to
get
the
names
of
the
callers
of
a
matlab
function
file,
use
dbstack
with
an
output
argument.
第4个回答  2009-12-15
pwd现实当前路径,再cd E:\... 然后在这个路径下编辑所含文件,会提示你是否改变路径或者添加路径的。
当然,也可以直接设置。
相似回答