Reading data using textscan
Reading data using textscan
(OP)
I have a data set in a text file, this file was written by ANSYS and it does not allow me to customize the way in which this particular file is written. I am pasting a typical section here
ROW 1 NODE 224 DEG. OF. FR. = TEMP
1-0.26430952E+01 2 0.58435712E+00 3 0.00000000E+00 4 0.00000000E+00
5 0.00000000E+00 6 2.00000090E+00 7 0.50000000E+00 8 0.70000000E+00
10 1.23000000E+00
After opening the file I can read the first line starting with ROW using
C = textscan(fid,'%s %d %s %d %s %s %s %s %s',1);
I tried writing format for the first numeric row in which 1 is the serial number and -0.26430952E+01 is the value.
The problem is caused by entries which are have negative numbers. 1-0.26430952E+01 cannot be discerned using two %n as there is no space between them. The serial numbers are of fixed with 5, but if I ask it to read using %5c then also it reads '1-0.2' into the cell.
Can some one help me in getting this file properly imported into Matlab.
Thanks and Regards
ROW 1 NODE 224 DEG. OF. FR. = TEMP
1-0.26430952E+01 2 0.58435712E+00 3 0.00000000E+00 4 0.00000000E+00
5 0.00000000E+00 6 2.00000090E+00 7 0.50000000E+00 8 0.70000000E+00
10 1.23000000E+00
After opening the file I can read the first line starting with ROW using
C = textscan(fid,'%s %d %s %d %s %s %s %s %s',1);
I tried writing format for the first numeric row in which 1 is the serial number and -0.26430952E+01 is the value.
The problem is caused by entries which are have negative numbers. 1-0.26430952E+01 cannot be discerned using two %n as there is no space between them. The serial numbers are of fixed with 5, but if I ask it to read using %5c then also it reads '1-0.2' into the cell.
Can some one help me in getting this file properly imported into Matlab.
Thanks and Regards





RE: Reading data using textscan
What happened to element 9??
RE: Reading data using textscan
ROW 1 NODE 224 DEG. OF. FR. = TEMP
1-0.26430952E+01 2 0.58435712E+00 3 0.00000000E+00 4 0.00000000E+00
5 0.00000000E+00 6 0.00000000E+00 7 0.00000000E+00 8 0.00000000E+00
9 0.00000000E+00 10 0.00000000E+00 11 0.00000000E+00 12 0.00000000E+00
13 0.00000000E+00 14 0.00000000E+00 15 0.00000000E+00 16 0.00000000E+00
17 0.00000000E+00 18 0.00000000E+00 19 0.00000000E+00 20 0.00000000E+00
21 0.00000000E+00 22 0.00000000E+00 23 0.00000000E+00 24 0.00000000E+00
25 0.00000000E+00 26 0.00000000E+00 27 0.00000000E+00 28 0.00000000E+00
29 0.00000000E+00 30 0.00000000E+00 31 0.00000000E+00 32 0.00000000E+00
33 0.00000000E+00 34 0.00000000E+00 35 0.00000000E+00 36 0.00000000E+00
37 0.00000000E+00 38 0.00000000E+00 39 0.00000000E+00 40 0.00000000E+00
41 0.00000000E+00 42 0.00000000E+00 43 0.00000000E+00 44 0.00000000E+00
45 0.00000000E+00 46 0.00000000E+00 47 0.00000000E+00 48 0.00000000E+00
49 0.00000000E+00 50 0.00000000E+00 51 0.00000000E+00 52 0.00000000E+00
53 0.00000000E+00 54 0.00000000E+00 55 0.00000000E+00 56 0.00000000E+00
57 0.00000000E+00 58 0.00000000E+00 59 0.14157049E+00 60 0.15559290E-01
61 0.00000000E+00 62 0.00000000E+00 63 0.00000000E+00 64 0.00000000E+00
65 0.00000000E+00 66 0.00000000E+00 67 0.00000000E+00 68 0.00000000E+00
69 0.00000000E+00 70 0.00000000E+00 71 0.00000000E+00 72 0.00000000E+00
73 0.00000000E+00 74 0.00000000E+00 75 0.00000000E+00 76 0.00000000E+00
77 0.00000000E+00 78 0.00000000E+00 79 0.00000000E+00 80 0.00000000E+00
81 0.00000000E+00 82 0.00000000E+00 83 0.00000000E+00 84 0.00000000E+00
85 0.00000000E+00 86 0.00000000E+00 87 0.00000000E+00 88 0.00000000E+00
89 0.00000000E+00 90 0.00000000E+00 91 0.00000000E+00 92 0.00000000E+00
93 0.00000000E+00 94 0.00000000E+00 95 0.00000000E+00 96 0.00000000E+00
97 0.00000000E+00 98 0.00000000E+00 99 0.00000000E+00 100 0.00000000E+00
101 0.00000000E+00 102 0.00000000E+00 103 0.00000000E+00 104 0.00000000E+00
105 0.00000000E+00 106 0.00000000E+00 107 0.00000000E+00 108 0.00000000E+00
109 0.00000000E+00 110 0.00000000E+00 111 0.00000000E+00 112 0.00000000E+00
...
and so on till serial number reaches 1189 and then again repeats in the same format and serial numbers but with different values ...
ROW 1 NODE 224 DEG. OF. FR. = TEMP
1-0.26430952E+01 2 0.58435712E+00 3 0.00000000E+00 4 0.00000000E+00
5 0.00000000E+00 6 0.00000000E+00 7 0.00000000E+00 8 0.00000000E+00
9 0.00000000E+00 10 0.00000000E+00 11 0.00000000E+00 12 0.00000000E+00
.... data-blocks repeats 1189 times.