how to import average and maximum data from excel sheet .

hi all:
i want to import avarege data of each day from above excel file but avarege of that values which is greater than 0.
second i want find greatest average value day in that excel file .
thanks

 Accepted Answer

[~,Num,Data]=xlsread('solar02.xlsx');
%Average values greater than zero
Average = mean(Data(2:end,3)>0);
%Maximum
max(Average);

12 Comments

thank you so much dear:
i have used your code but it gave me this error .
Undefined operator '>' for input arguments of type 'cell'.
Error in SOLARRR (line 3)
Average = mean(Data(2:end,3)>0);
this will also work for you.
[Num,text,Data]=xlsread('solar02.xlsx');
Average=mean(Num>0)
thanks dear:
it will give us average of all the values but i need each day average for all data given excel file .
thanks
as you know we have 365 day in one year so output will be 365 values but average value of each day dear.
thanks
let me explain my problem dear :
i need average of each day i want to take average of those values in each day which is grather than 200.
thanks
thanks dear Sudhakar Shind:
i used this code but it gives me average of all values in each day i mean not greather than 200.
[numbers, strings, rawData] = xlsread('solar02.xlsx')
daysOfWeek = strings(2:end, 2);
sequentialDays = ones(length(daysOfWeek), 1);
for k = 2 : length(sequentialDays)
if ~strcmpi(daysOfWeek{k}, daysOfWeek{k-1})
% It's not the same as the prior day so we're starting a new day.
sequentialDays(k:end) = (sequentialDays(k-1) + 1);
end
end
% Get the averages over any and all hours of each day.
dailyAverages = splitapply(@mean, numbers, sequentialDays);
plot(dailyAverages, 'b-', 'LineWidth', 2);
title('Daily Average of Solar Radiation', 'FontSize', 18);
xlabel('Day', 'FontSize', 18);
ylabel('Average over the Day', 'FontSize', 18);
grid on;
but my purpose is that first of all matlab should ignor all those values which are less than 200 and than take average of each day i hope you got my point.
thanks
does this works:
% Get the averages over any and all hours of each day.
dailyAverages = splitapply(@mean, numbers>200, sequentialDays);
hi:
it gives me an error of (' empty double column vector')
thanks
This is your area of interest:
%Use below code lines in your code:
Id = (numbers>200);
numbers=numbers(Id);
sequentialDays = sequentialDays(Id);
G = findgroups(sequentialDays);
% Get the averages over any and all hours of each day.
dailyAverages = splitapply(@mean, numbers, G);
Done thank u so much dear from your helping and support.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Products

Release

R2017a

Community Treasure Hunt

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

Start Hunting!