Hi, I have a lot of files that are named based on their date (ex: 20140702.csv is July 2 2014). I need to save the data in these files under one structure called r. So I would like to have it called r.file_20140702. How do I change the fieldname from '20140702' to 'file_20140702'? Matlab won't accept 'r.20140702'.

답변 (1개)

Star Strider
Star Strider 2014년 11월 19일

0 개 추천

Here’s one way:
filename = '20140702.csv';
fildate = filename(1:strfind(filename,'.csv')-1);
fieldname = ['file_' fildate];

댓글 수: 2

Stacey
Stacey 2014년 11월 19일
I fixed it this way:
fieldname = strcat('file_',fieldname);
Star Strider
Star Strider 2014년 11월 19일
I don’t understand, since it doesn’t seem to be what you asked in your Question, but if it works, go with it.

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

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

질문:

2014년 11월 19일

댓글:

2014년 11월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by