Reputation: 336
I'm trying to create a file using fopen in a subfolder in Matlab.
In my project directory I have a folder 'logs' so I tried this:
filename = 'log.txt';
date_format = 'mmm_dd_yyyy_HH:MM';
time_stamp = datestr(now, date_format);
file2 = fullfile('logs', strcat(time_stamp, filename));
fid = fopen(file2, 'w');
I get the error:
The file name contains characters that are not contained in the filesystem encoding. Certain operations may not work as expected.
I think it's a formatting issue but I can't figure out what is wrong.
Edit: In case it matters... Windows 7 and Matlab R2016a
Upvotes: 0
Views: 394
Reputation: 2919
Remove the colon (:).
date_format = 'mmm_dd_yyyy_HH_MM';
In windows, filenames can't contain /:*"<> and ? marks.
Upvotes: 1