Read all files inside more than one directory

조회 수: 2 (최근 30일)
Mini Me
Mini Me 2014년 9월 11일
댓글: Mini Me 2014년 9월 16일
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에서 Environment and Settings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by