Read all files inside more than one directory

1 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2014-9-11
See my attached demo that recurses into all subdirectories and lists files.
  18 个评论
Image Analyst
Image Analyst 2014-9-13
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 2014-9-16
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by