Azzera filtri
Azzera filtri

Extracting number array from mixed-format data.

1 visualizzazione (ultimi 30 giorni)
Ardo Laaneots
Ardo Laaneots il 28 Nov 2017
Hello.
I am trying to extract a array of numbers from a .txt file that has mixed-format data.
With textscan I can find all of the instances of keyword "Total temperatures".
%%Import Safir output file
FileName="PROOV_666.txt";
%%Read the txt file
FID = fopen(FileName, 'r');
if FID == -1
error('Cannot open file')
end
Data = textscan(FID, '%s', 'delimiter', '\n', 'whitespace', ' ' );
CStr = Data{1};
fclose(FID);
%%Find string
Index = strfind(CStr, 'TOTAL TEMPERATURES');
IndexA = find(not(cellfun('isempty', Index)));
How do I extract array of numbers between the first and second instance of "Total temperatures", then between second third instance and so on. The array of numbers has a fixed number of columns but the number of rows can vary. Also in the .txt file the numbers are delimited by spaces/tab. Here is a example of the .txt file:
TOTAL TEMPERATURES.
--------------------
NODE TEMP. NODE TEMP. NODE TEMP. NODE TEMP. NODE TEMP.
1 20.0 2 20.0 3 20.0 4 20.0 5 20.0
6 20.0 7 20.0 8 20.0 9 20.0 10 20.0
... ... ... ... ... ... ... ... ... ...
26121 87.8 26122 87.8 26123 87.8 26124 87.8 26125 87.8
26126 87.8 26127 87.8 26128 87.8 26129 87.8 26130 87.8
TIME= 60.0000 SECONDS OR 1 MIN. 0 SEC.
===========================================
CONVERGENCE HAS BEEN OBTAINED.
=============================
TIME = 60.00000
TOTAL TEMPERATURES.
--------------------
NODE TEMP. NODE TEMP. NODE TEMP. NODE TEMP. NODE TEMP.
1 20.0 2 20.0 3 20.0 4 20.0 5 20.0
6 20.0 7 20.0 8 20.0 9 20.0 10 20.0
I would like to create a individual array for each instance - so I could refer to each of then separately later on.

Risposte (0)

Categorie

Scopri di più su Large Files and Big Data 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