How to import a particular text file and plot.
Show older comments
Here is the data that I wish to import:
Scan(+/- seconds),Sensor1Value,Sensor2Value,Sensor3Value,Sensor4Value
-1, 2, 8, 3, 4
'#' Comment Here
9, 0, 5, 6, 7
-------------------------------------
If I want to plot this kind of data,
fid = fopen(file.txt');
% read column headers
header = textscan(fid, '%s', 5, 'delimiter', ',', ... 'commentStyle', '#');
% read numeric data
data = textscan(fid, '%f %f %f %f %f', 'delimiter', ',', ... 'commentStyle', '#');
fclose(fid);
------------
My question is, when I type in header{1} I get all five columns. Shouldn't it be the case that if I type in header{1}, header{2}, header{3},...,header{5} I should get: Scan, Sensor1Value, Sensor2Value,...,Sensor4Value respectively?
Accepted Answer
More Answers (0)
Categories
Find more on Text Data Preparation 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!