Azzera filtri
Azzera filtri

Import column from files

2 visualizzazioni (ultimi 30 giorni)
Momo
Momo il 12 Lug 2013
Hello,
I have 200 files with names starting from 3201.rad to 3396.rad, each files has header (5 lines of text), 1057 raw and 3 columns. I want to create a matrix with the second column of each file, without the header. Matrix with 1057 raw, 196 column.
Thank you in advance for your help!
M.

Risposte (1)

Matt J
Matt J il 12 Lug 2013
A=zeros(1507,196);
for i=3201:3396
filename=[num2str(i) '.raw'];
A(:,i) = dlmread(filename,'',[5,1,1511,1]);
end
  2 Commenti
Momo
Momo il 12 Lug 2013
Thank you Matt for your respons. However, it does not work. it gives me the message below
??? Error using ==> dlmread at 145 Mismatch between file and format string. Trouble reading number from file (row 1, field 5) ==> \n
I don't know how I can solve this problem. In details this is the data in files (4 columns, 1073 rows, 5 lines in header )
without numbers 1, 2, 3, 4, 5 in rows
  1. 3201.rad
  2. center 668.60 831.10 -> 668.14 832.82, r_max 1070.04
  3. radius binding according to
  4. 1 sectors on 360 degs with origin at -180.00 deg, 0.00 deg
  5. a I e/s n ...
  6. 0.0 102215.03 1915.55 4.6
  7. 1.0 105897.02 4812.49 9.9
  8. 2.0 108802.90 3875.25 16.4
  9. ....
  10. ..... # ......
  11. 1072.0 108802.90 3875.25 16.4
I have 196 files with this data, and I would like to tranfer only the 2nd column of all files to a matrix.
Thank you very much
Matt J
Matt J il 12 Lug 2013
Modificato: Matt J il 12 Lug 2013
Works fine for me, Momo. What version of MATLAB are you using and are you sure you're calling DLMREAD with 3 input arguments, like in what I posted?
The error message says it's trying to read row 1, field 5. It should not be doing that if you've called it with the 3rd argument.

Accedi per commentare.

Categorie

Scopri di più su Structures in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by