I try to import data from a text file to MATLAB, which has the following structure:
** Porosity
**
*POR *ALL
0.1500 0.0900 2*0.1300 0.1400 4*0.1500 0.2200 2*0.1500 0.0500
0.0900 0.1400 5*0.1500 0.2300 0.2600 0.0800 0.1500 0.1500 0.2400 0.1700
[...]
The header has to be ignored obviously. Space is the delimiter, while * indicates that the same value occurs several times as indicated by the integer before the *.
Unfortunately, the number of entries per line varies. Ideally I want to store all values in one array like this:
por = [0.1500 0.0900 0.1300 0.1300 0.1400 0.1500 0.1500 0.1500 0.1500 0.1500 0.2200 0.1500 0.1500 ...]
Can this be solved with the textscan command somehow? The file is rather large with some hundred thousand values, so I need a quick solution ;) Help is greatly appreciated!
fid = fopen('file'); data = textscan(fid,'%s','delimiter',' '); fclose(fid). then you will have to examine each cell indatafor*and build your numerical array - Trogdor