Read all files inside more than one directory

1 visualización (últimos 30 días)
Mini Me
Mini Me el 11 de Sept. de 2014
Comentada: Mini Me el 16 de Sept. de 2014
Hello, I have a data directory that has 2 more subdirectories which contain binary data in them. the binary data are chunks of 100Sa/s binary files of data taken over a period of time. I want to read all the data inside both directories and manipulate them. in addition, All data in each directory should construct a plot. so far this is what i have and I keep getting errors when i am trying to open the files.
Files=dir('*.*');
Arrayfile=[]
for k=1:length(Files)
FileNames=Files(k).name
if Files(cnt).isdir, continue
Arrayfile=[Arrayfile;FileNames]
fid=fopen(filedir(cnt).name, 'rb', 'ieee-be')%file open inside
timestamp = fread(fid,4,'uint32');
dt = fread(fid,1,'float64');
cols=fread(fid,1, 'uint32');%get the column size
rows=fread(fid,1,'uint32');%get the row size
data=fread(fid,[rows,cols],'double')% get the full data r x c
end
end

Respuesta aceptada

Image Analyst
Image Analyst el 11 de Sept. de 2014
See my attached demo that recurses into all subdirectories and lists files.
  18 comentarios
Image Analyst
Image Analyst el 13 de Sept. de 2014
use either comma or semicolon depending if you want to append horizontally or vertically.
allData{k} = [allData{k}, thisFData]; % Stitch side by side
allData{k} = [allData{k}; thisFData]; % Stitch vertically
Mini Me
Mini Me el 16 de Sept. de 2014
Thanks @ Image Analyst so I decide to take the mean of allData{k}. Now the mean will be one value for each row. meaning a 1 x 8 matrix. I want to take each column of that matrix and feed inside a new array each time the loop read a folder of data files (k loop). meaning I want the average of all the files in folder one. take the 1st column and feed in an array, take the second and feed it in an other array. and so on. move on to the 2nd folder, it takes the 1st column and feed in the same array that contain the first column of the previous folder. then the same for the second folder and so on. If can help me it'd be much appreciated as I am stuck on this for a while now

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by