필터 지우기
필터 지우기

Create a subfolder with datetime as its name using mkdir

조회 수: 38 (최근 30일)
Moritz Pohl
Moritz Pohl 2018년 2월 27일
편집: NISARGA G K 2018년 3월 8일
Hello folks,
I currently try to create a subfolder in my 'Results' folder which shall be named after the time and date the program was used. So far, this is what I have:
currDate = strrep(datestr(datetime), ' ', '_');
mkdir Results currDate
The problem is that mkdir does not recognize currDate as a char vector. So the created folder is named 'currDate' and not '27-Feb-2018_...'. Can anyone help me out?
Cheers

답변 (1개)

NISARGA G K
NISARGA G K 2018년 3월 8일
편집: NISARGA G K 2018년 3월 8일
Hi Moritz
I understand that, you want to create a subfolder with the time and date the program was used as name of the subfolder. 1)Colon is a reserved character and cannot be used in naming the folder. 2)Use function syntax than command syntax while passing variable to 'mkdir'. The following link would help you in understanding better:
https://www.mathworks.com/help/matlab/matlab_prog/command-vs-function-syntax.html
The below code snippet would serve the purpose:
currDate = strrep(datestr(datetime), ':', '_');
mkdir('Results',currDate)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by