Effacer les filtres
Effacer les filtres

Open multiple .WTD files and create a matrix to perform calculation

2 vues (au cours des 30 derniers jours)
Damith
Damith le 23 Avr 2014
Modifié(e) : Damith le 24 Avr 2014
Hi,
I have 39 .wtd files (see a sample of attached file) and need to read the 1st and 4th columns. Then I need to create a data matrix [0001(:,4) 0002(:,4)...0039(:,4)]. Please help me to create this.
See the 0001.wtd attached.
Thanks for any help in advance.
  7 commentaires
Star Strider
Star Strider le 24 Avr 2014
Modifié(e) : Star Strider le 24 Avr 2014
I unzipped it to a ‘.wtd’ file, and then couldn’t find an application that would read it. What is it? I suggest you open it and save it as a PDF, then upload the PDF version.
How do you open it in MATLAB? Does it require a specific Toolbox?
Posting the relevant section of code that opens it would help.
Walter Roberson
Walter Roberson le 24 Avr 2014
The file is a text file; for example on OS-X I can open it with Text Wrangler without difficulty.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 24 Avr 2014
all_col1 = [];
all_col4 = [];
then start file loop, and for each
fid = fopen(filename_variable_goes_here, 'r');
col1_4_cell = textscan(fid, '%f%*f%*f%f', 'headerlines', 1, 'CollectOutput', 1);
col1_4 = col1_4_cell{1};
all_col1 = vertcat(all_col1, col1_4(:,1));
all_col4 = vertcat(all_col4, col1_4{:,2));
  3 commentaires
Walter Roberson
Walter Roberson le 24 Avr 2014
The line I posted has code outline of how to read a series of files.
all_col1 = [];
initializes a variable named "all_col1" to be the empty matrix. The vertcat() is then used to append information to the bottom of the matrix.
If you use the second batch of code in the link I posted above, the one that reads the file names out of the directory, then filename_variable_goes_here should be changed to fullFileName
Damith
Damith le 24 Avr 2014
Modifié(e) : Damith le 24 Avr 2014
I tried your code and all_col1 and all_col4 are empty. Here is the code I tried: I tried reading the attached 0001.wtd file.
all_col1 = []; all_col4 = [];
fid = fopen('0001.wtd', 'r');
col1_4_cell = textscan(fid, '%f%*f%*f%f', 'headerlines', 1,'CollectOutput', 1);
col1_4 = col1_4_cell{1};
all_col1 = vertcat(all_col1, col1_4(:,1)); all_col4 = vertcat(all_col4, col1_4(:,2));

Connectez-vous pour commenter.

Catégories

En savoir plus sur Large Files and Big Data dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by