File import
Show older comments
Hallo,
I would like to import in Matlab a set of data, which originally is expressed in 4 columns: ex:
1490 3 2 0.
20094 1 2 0.
66779 4 2 0.
14293 3 2 0.
53990 1 2 0.
61190 4 2 0.
I want it to be imported as one column excluding the 4th columnm, and combining the 3 numbers for each row in one number like this:
1490*3*2
20094*1*2
66779*4*2
14293*3*2
53990*1*2
61190*4*2
How can I use the function textscan to do it? are there other ways to do it?
Thanks.
Sami
Accepted Answer
More Answers (1)
Oleg Komarov
on 23 Jul 2011
fid = fopen('yourpath.txt');
out = textscan(fid,'%f%f%f%*f','CollectOutput',1);
out = sum(bsxfun(@times, out{1}, [100 10 1]),2);
fid = fclose(fid);
Categories
Find more on Text Files in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!