Textscan cannot return anything in Matlab 2013a

1 view (last 30 days)
Dear users
I am using Matlab 2013a on my MAC. I am working on other people's code now to extract string from txt file. These codes work well on Matlab-Windows version but they can not work under my Matlab-MAC version and also my college's Matlab-MAC version:
K>> fnames
fnames =
Index,Initials,Name,MiddleName,LastName,Date
K>> res=textscan(fnames,'%s','delimiter',',')
K>> res
Undefined function or variable 'res'.
fnames is a header string extracted from a txt file using strtok() function
I tried to manually replace fnames with a written string, it works:
K>> fnames='Index,Initials,Name,MiddleName,LastName,Date';
K>> res=textscan(fnames,'%s','delimiter',',')
res =
{6x1 cell}_ _
I am very confused about this, anybody came up with the same problem?
  3 Comments
Tianxiao
Tianxiao on 4 Mar 2014
Sorry for the delay~~ Yes, I found that there is a hidden 'return' value in this variable, after I delete it, it works, Thank you!
Tianxiao
Tianxiao on 4 Mar 2014
This problem came from the different new line character used between Windows and Mac txt editor, right?

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!