how to select columns of data (.dat)

i have data in 732 file (.dat ) n this sample my data..
03:05:00 .000 065.501 01** 4864 0086 0074 +19
03:06:00 .000 065.501 01** 4862 0095 0074 +19
03:07:00 R- .026 065.501 01** 4862 0105 0074 +19
03:08:00 R- .180 065.504 01** 4864 0105 0074 +19
now i want to plot column 1 (time) with (column 3) divide 60 (rain) ..
1. how i can do that, because i think sometimes matlab read my data just have 8 column (when no rain (R-)). n sometimes matlab read 9 column.
when no rain R- replace with 2 space
2. how i can read all file.

2 Commenti

A loop, "fgetl Read line from file, removing newline characters", and test for "R-" is one possibility.
Soni huu
Soni huu il 26 Giu 2012
write the scrip please.. i don know what do u mind..

Accedi per commentare.

 Risposta accettata

Walter Roberson
Walter Roberson il 26 Giu 2012

1 voto

You can use textscan(), and at the place where you might have the R- or might not, use %2c as the format. %c does not skip blanks. (Experiment: there is a chance you might need to use %*c%2c instead, to eat the space between fields.)

5 Commenti

Soni huu
Soni huu il 26 Giu 2012
can u try my data please.. iam newbie..
Do you need the leading 0's preserved? Do you need the '+' to be preserved? Should the two characters shown as '**' in your example data be read in? If so then should the 01** be a single field or two fields?
Soni huu
Soni huu il 26 Giu 2012
0's= no
+= no
yes the '01**' is single field..
sorry my answer is short. coz my engglis not good..
Soni huu
Soni huu il 27 Giu 2012
please... help me..
Soni huu
Soni huu il 28 Giu 2012
Modificato: Soni huu il 28 Giu 2012
i read this to delimited the data, but the data just show in 1 culoumn..
fid = fopen('09-25-2010.dat','r'); InputText=textscan(fid,'%8c%*c%2c%*c%4c%*c%7c%*c%4c%*c%4c%*c%4c%*c%3c'); Intro=InputText{1}; disp(Intro);

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Import and Analysis in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by