Monday, September 14, 2020

Tip when reading data from file

When I read data from a file in Matlab, I sometimes read the wrong file because files have the same name but different paths and I want to read the latest file. If you print the file date/time to Matlab's command window, you will get a visual indication which can alert you if you read an older file with the same name. You can use the following two lines to print file date:
fileInfo = dir(fileName);
fprintf("File date: %s\n", fileInfo.date);

No comments:

Post a Comment