MATLAB: How to import average of monthly data from excel file

image analysisimage processingMATLABmonthly averagesolar radiation

hi to all:
i hope you all well be fine and doing well.
i want to import average solar radiation of each month from given excel file but the average of those data which is greather than 200 and same for weeks .
thanks

Best Answer

hello
this is a simple code that will extract monthly data and look for solar radiation above 200
each month data will then be stored in a separate sheet in a excel file (so 12 sheets total)
[data, text, alldata] = xlsread('solar.xlsx');
% Year Month Day Hour solar_radiation
% i want to import average solar radiation of each month from given excel file
% but the average of those data which is greather than 200 and same for weeks .
% % ind of data that exceed 200 in solar_radiation
% ind = find(ndata(:,5) > 200)
[m,n] = size(data);
month = (min(data(:,2)):max(data(:,2)));
filename_out = 'test.xlsx';
% data selection
for ci = 1:length(month)
ind = find(data(:,2) == month(ci))
data_one_month = data(ind,:);
% ind of data that exceed 200 in solar_radiation
ind = find(data_one_month(:,5) > 200)
data_selected = data_one_month(ind,:);
[mm,nn] = size(data_selected);
% export to excel
OUT(1,1:n) = text; % paramters in firts line
OUT(2:mm+1,1:n) = num2cell(data_selected); % averaged data in second line
writecell(OUT,filename_out,"Sheet" ,ci); % save OUT to excel file
end