How can I do same calculation with a lof of excel files in matlab?

2 vues (au cours des 30 derniers jours)
afrya
afrya le 18 Déc 2014
Commenté : afrya le 18 Déc 2014
Hello,
I ' m working with an excel file in matlab.After importing the excel file in matlab, I do some calculations. I would like to do the same calculations in my programm but with a lof of excel files. Do you have any idea how to do that? Here is my code :
data=xlsread('HM_VN77_31_Fn=15N.xlsx','A9:G4214');
t=data(:,1);
Fn=data(:,2);
Ft=data(:,4);
%%%%%Calcul%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SFn = sgolayfilt(Fn,2,101);
SFt=sgolayfilt(Ft,2,101);
mu=-SFt./SFn;
mu1=mean(mu,1)
MFn1=mean(SFn,1);
Mft1=mean(SFt,1);
Thank you in advance

Réponses (1)

Peter Borda
Peter Borda le 18 Déc 2014
I would put all the xls files in the same folder for start, use matlab's dir() function to get the file names in the folder, then make a loop which checks whether the actual file is xls or not.
listing = dir(name);
NumOfFiles = length(listing);
for k = 3:NumOfFiles % strarts from 3, because the first and second elements are '.' and '..'
ActFile = listing(k).name;
if strcmp(ActFile(end-2:end),'xls' ) || strcmp(ActFile(end-3:end) ,'xlsx')
%insertr your code here
end
end
  1 commentaire
afrya
afrya le 18 Déc 2014
Thank you for your answer, It work only for one excel file. I think a for loop would be necessary to perform the calculations for all excel files.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by