how to find average signal from different excel sheets?

조회 수: 1 (최근 30일)
Amit Kadarmandalgi
Amit Kadarmandalgi 2019년 2월 25일
댓글: Bob Thompson 2019년 2월 25일
I have 100 excell sheets each with a 500 sample signal V clocked to time t.
How to find the average signal (V) using all 100 excell sheets aas we can import only one data set at a time.

채택된 답변

Bob Thompson
Bob Thompson 2019년 2월 25일
You can load and save the data with a for loop and then average afterwards. Alternatively, if you really want you can maintain a running average within a for loop again.
% First method
for i = 1:100
data(:,:,i) = xlsread('myfile.xlsx',i);
end
V_ave = mean(data);
% Second method
V_ave = [];
for i = 1:100
data = xlsread('myfile.xlsx',i);
V_ave = (V_ave*(i-1)+mean(data))/i;
end
  댓글 수: 2
Amit Kadarmandalgi
Amit Kadarmandalgi 2019년 2월 25일
this is ok but isnt it same as importing every excel and finding average i have named my excel 1 2 3 4...100 so is it possible to read files 1 to 100 and i think you meant 1:500 as there are 500 samples in each excell sheet
Bob Thompson
Bob Thompson 2019년 2월 25일
The sample I gave will read 100 sheets of a single excel document. If you don't want that then you need to adjust the excel document name:
data(:,:,i) = xlsread(['myfile_',num2str(i),'.xlsx']);
Either way, the xlsread command is kind of a one off thing. Each time you call the command you can open one file to one sheet and reed in the data. If you want more sheets, or more files, you need to call the command each time.
Pretty much any load command works in a similar fashion within MATLAB, so while it might be worth calling the ActXServer to speed the process, you're still going to need to loop the loading command, as far as I know. (The ActXServer is a functionality within MATLAB which allows you to open Excel within MATLAB, which may save you time because you do not need to open and close Excel each time you load a file, like you do with the xlsread command.)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by