Missing text filename string

조회 수: 6 (최근 30일)
Scott Williams
Scott Williams 2017년 4월 9일
댓글: Scott Williams 2017년 4월 10일
I've got code working fine in Matlab 2012 student on Mac. When I try to run it on Windows 7 it doesn't work. For some reason the filenames that I am using become shortened. The commands in the attached picture demonstrate my problem. Is there a way to force the full filenames into strings?
  댓글 수: 1
Jan
Jan 2017년 4월 9일
Please post the code as text, not as screenshot. Screenshots impede using the original data by copy&paste.

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

채택된 답변

Jan
Jan 2017년 4월 9일
편집: Jan 2017년 4월 9일
You did not explain how the file names look like originally. The screenshot looks like e.g. the 2nd file is called:
'04-08-2017 10:40:45 PM.txt'
This is not a valid file name under Windows, because colons are forbidden inside names. They are used to markl a disk drive letter. You can expect that either the Matlab commands or the access through the OS will fail.
The only solution is to rename the files - preferrably on the Mac to avoid confusions.
By the way: Do not use "path" as the name of a variable, because this shadows an important Matlab command. Prefer fullfile to join file names, because it considers the file separators in opposite to strcat.
The format for the file names is clumsy. With:
'2017-08-04 22_40_45.txt'
'2017-08-04 09_40_45.txt' % '09' instead of '9'
the temporal would equal the alphabetical order.
Note: These characters are not allowed in file names:
: > < ? * / \ | "
Avoid such file names also:
CON, PRN, AUX, NUL, COM1...COM9, LPT1...LPT9
even if a file extension is appended.
  댓글 수: 3
Scott Williams
Scott Williams 2017년 4월 10일
Thanks for your answers, it gives me a better understanding as to why I am experiencing these problems. I am trying to automate a data interpretation process where .txt document filenames with colons are generated by a device at the time data processing starts. These filenames are same as in text box illustrated above. I would also like to omit the 9 in '09' date for instance but as I'm using string manipulation for graph titles it is helpful to keep strings the same length.
Your explanation has helped me to explain why I had this problem, and why my .csv filenames generated are not expressed with colons. I'm thinking it is a small miracle that the process even works on the Mac alone. Phew!
Thanks
Scott Williams
Scott Williams 2017년 4월 10일
And thanks also for the link on ISO8601.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by