How to take average values of different excel files using matlab and also how to write them -
for example have filenames 12120100.xls 12120123.xls. need take average of data of these files , need write(xlswrite) these files separately different name. filename 12120100 represents 12=year,12=month,01=day,00=hour.here want give year ,month,day inputs , hour(00 23) used in loops in code since hour
%% here code used
clc; close all; clear all; d='12120722.xls'; % file want read ,avg , xlswrite dat=xlsread(d,'f3:ah3602'); size(dat) avg=zeros(1,29); i= 1:29 avg(i)=mean(dat(1:3600,i)); end avg newfname=strcat(d(1:8),'averaged values','.xls'); xlswrite(newfname,avg,' f1:ah1'); h=msgbox('averaged complete') close(h);
the above code 1 file. ii want code 22 files operation @ time
thanks in-advance
put excel file want process in 1 folder , run code folder.
fname=dir('*.xls'); % read in file names f=1:length(fname) d=fname(f).name; % file want read in current iteration d dat=xlsread(d,'f3:ah3602'); size(dat) avg=zeros(1,29); i= 1:29 avg(i)=mean(dat(1:3600,i)); end avg newfname=strcat(d(1:8),'averaged values','.xls'); xlswrite(newfname,avg,' f1:ah1'); h=msgbox('averaged complete') close(h); end
Comments
Post a Comment