필터 지우기
필터 지우기

How to use variables as filename when saving to a .csv file

조회 수: 4 (최근 30일)
JB
JB 2015년 11월 4일
댓글: Image Analyst 2015년 11월 4일
Hello, I have a program,which takes start date and end date from user,I would like to use the variables as the filename when outputing to a .csv file. I have the following variables :
start_date =[2015, 1, 1];
end_date = [2015, 1, 2];
I want my csv file to be saved in this manner:
output_filename = "start_date " -- "end_date"--"data".csv.
Note: start_date is 1x6 double and end_date is 1x3 double and outputfilename is storing file name to be saved.
Thanks alot in advance.

채택된 답변

Thorsten
Thorsten 2015년 11월 4일
편집: Thorsten 2015년 11월 4일
output_filename = [datestr(datenum(start_date), 'yyyy-mm-dd') ' -- ' datestr(datenum(end_date), 'yyyy-mm-dd') '--data.csv']
  댓글 수: 2
JB
JB 2015년 11월 4일
Thanks alot, i was not considering 'datenum' in account. Thanks again..
Image Analyst
Image Analyst 2015년 11월 4일
If you're used to C, you might find it easier to use sprintf() to create the filename.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by