Averaging columns from multiple excel files
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, I have several excel files and would like to do some analysis and then average the results.
I've attached a sample file to help explain my question (the actual files have a lot more data). I wrote a sample code to get the get the first two columns in a certain time range:
file_folder = 'C:\Users\J\Desktop\'
file1 = [file_folder 'example.xls']
sheet = 1;
%get start & stop values
start = xlsread(file1, sheet, 'B4')
stop = xlsread(file1, sheet, 'B5')
%read all columns
col1 = xlsread(file1, sheet, 'A8:A18');
col2 = xlsread(file1, sheet, 'B8:B18');
time_column = xlsread(file1, sheet, 'C8:C18');
%index of start and stop value in time column
start_index = find(time_column==start)
stop_index = find(time_column==stop)
%get columns 1 and 2 in given time frame
col1_time = col1(start_index:stop_index)
col2_time = col2(start_index:stop_index)
My question now is how I can do this to several files and then compare (e.g. average) the columns? For example, I need to get all the col1_time for each file (each file has different start and stop times).
I thought I could loop through all my excel files, but then I'm overwriting the array where my data is stored. The only way I could think of is to loop through the files, create a new excel file every time and then loop through all the new files... though I'm not sure this is the best approach.
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!