Multipul textscan into one matrix
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
Hey,
I'm new to Matlab and have no experience in textscan functions..
I have 3 folders, each of them containing 4 text files with a data that have the same format in all :
"Filed_Size(square_meter) Total_Product(ton) Grade_A_Product(ton) Grade_B_Product(ton) Grade_C_Product(ton) Sweetnes(1-100) Shelf_Life(days)"
, but with different numbers in every category.
I got an assignment, to read all the data from these 3 folders(12 text files= 3 folders*4 text files in each) into one matrix. I tried to loop with "fopen" for each folder seperatly but than I get a folder ID of (-1).
this is what I have for now-
file_id_lot247_2017 = fopen('2017_lot_no_247_Data.txt');
file_id_lot247_2016= fopen('2016_lot_no_247_Data.txt');
file_id_lot247_2015= fopen('2015_lot_no_247_Data.txt');
file_id_lot247_2014= fopen('2014_lot_no_247_Data.txt');
As you can see, I have a folder name 247 and I need to read all the text files from it..but I have tow more folders to read and I need ALL the 12 text scan to be in one matrix.
the text in each look like this- **the numbers changes in each text**
Filed_Size(square_meter) Total_Product(ton) Grade_A_Product(ton) Grade_B_Product(ton) Grade_C_Product(ton) Sweetnes(1-100) Shelf_Life(days)
406 12 5 6 1 65 12
Can someone help me please?
Thank you!
1 comentario
dpb
el 28 de Dic. de 2019
See IA's demo to traverse subdirectories at link <Read-all-files-inside-more-than-one-directory>. Use dir() with wildcard to return all of a given lot number (if more than one there, altho perhaps what you're meaning is there are a bunch of different lot numbers?)
Need to know a little more about the storage organization and naming and whether there are other files besides to be able to be precise, but that's general idea. Don't create file handles with the metadata in the name; just use a single fid and handle each file in a loop one at a time, keeping track of which year and lot is which by variables or other storage organization depending upon just what it is that is being done.
Respuestas (0)
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!