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

 Respuesta aceptada

Sudhakar Shinde
Sudhakar Shinde el 20 de Oct. de 2020
Editada: Sudhakar Shinde el 20 de Oct. de 2020
[~,Num,Data]=xlsread('solar02.xlsx');
%Average values greater than zero
Average = mean(Data(2:end,3)>0);
%Maximum
max(Average);

12 comentarios

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);
Sudhakar Shinde
Sudhakar Shinde el 22 de Oct. de 2020
Editada: Sudhakar Shinde el 22 de Oct. de 2020
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
Sudhakar Shinde
Sudhakar Shinde el 22 de Oct. de 2020
Editada: Sudhakar Shinde el 22 de Oct. de 2020
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.
Welcome. glad to help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import and Analysis en Centro de ayuda y File Exchange.

Productos

Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by