string variable and command prompt

8 次查看(过去 30 天)
I know you can use a string variable with cd such as dir = 'C:Users\User\Documents\Matlab' then cd(dir). Is that same type of command possible using the system command such as [status] = system('move dir\file.txt newlocation')
  2 个评论
Adam
Adam 2018-6-20
I would have though you could try it and get an answer far faster than on here! As far as I know the string you give to the system function will be interpreted in the context of the command line so if it is valid in that context then it would work, otherwise not.
Stephen23
Stephen23 2018-6-20
编辑:Stephen23 2018-6-20
Why do you need to system for this? movefile is simpler and faster.

请先登录,再进行评论。

采纳的回答

Philip Borghesani
Philip Borghesani 2018-6-20
Short answer: yes.
Long answer: Any MATLAB function that takes one or more character vectors as input can be called in command mode see command-vs-function documentation for more information.
I am a bit surprised you had to ask is something not working the way you expect it to?
  4 个评论
Keith Holmlund
Keith Holmlund 2018-6-20
thank you both, that ended up working
Philip Borghesani
Philip Borghesani 2018-6-20
You might try movefile for this instead. Error handling will be simpler, it can work on all platforms, and it is probably faster.

请先登录,再进行评论。

更多回答(0 个)

类别

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

标签

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by