MATLAB Answers

string variable and command prompt

조회 수: 15(최근 30일)
Keith Holmlund
Keith Holmlund 2018년 6월 20일
편집: Stephen 2018년 6월 20일
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
Stephen 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
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개)





Community Treasure Hunt

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

Start Hunting!

Translated by