How to read different data types from a txt file
5 views (last 30 days)
Show older comments
Hi all, How can I read this file and assign each line to a variable
USB
00000001
8
10000000111
128
0.0000008
0 Comments
Accepted Answer
Guillaume
on 13 Dec 2019
lines = strsplit(fileread('C:\somewhere\yourfile'), {'\r', '\n'});
lines will be a cell array with each cell containing a line of your text file.
2 Comments
Guillaume
on 13 Dec 2019
You're going to have problems reading 80e-9 as integer!
Anyway
str2double(lines(2:end))
will convert all but the first line to real numbers.
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB 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!