Textscan and file paths work on my MacBook, but not on Windows 7
Show older comments
I wrote a script on my MacBook (running MATLAB 2011a) that works just fine (in a loop, it reads a few files of test data, plots relevant parts, then repeats). I need to hand it off to my boss who runs MATLAB 2007 on a PC, but it won't run.
Inside the loop, I've been using textscan to read the data from .csv files, like this:
FID = fopen(['PEMS_event/',files{N,3}]);
event = textscan(FID,'%f %d %s',inf,'delimiter',',');
event_t = event{1};
event_ID = event{2};
fclose(FID);
where files{N,3} refers to a matrix of .csv filenames defined earlier.
The fopen command seems to work (FID is a positive integer), but 'event' is an array of empty arrays/cells.
I suspect the problem has to do with the file path, but the same problem occurred when I moved the files directly into the current directory and removed the folder 'PEMS_event/' from the path specification.
I also tried using xlsread (I understand it works well with windows, not with macs) with the file in the current directory like this:
[data text] = xlsread('bb_event_2013-08-19_15-16-09.csv');
but this just gave me an error:
??? XLSREAD unable to open file bb_event_2013-08-19_15-16-09.csv.
Undefined function or variable 'name'.
Help? I'm confused. Thanks in advance.
Accepted Answer
More Answers (0)
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!