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

 採用された回答

Sudhakar Shinde
Sudhakar Shinde 2020 年 10 月 20 日
編集済み: Sudhakar Shinde 2020 年 10 月 20 日

0 投票

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

12 件のコメント

Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 20 日
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 2020 年 10 月 22 日
編集済み: Sudhakar Shinde 2020 年 10 月 22 日
this will also work for you.
[Num,text,Data]=xlsread('solar02.xlsx');
Average=mean(Num>0)
Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 22 日
thanks dear:
it will give us average of all the values but i need each day average for all data given excel file .
thanks
Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 22 日
as you know we have 365 day in one year so output will be 365 values but average value of each day dear.
thanks
Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 22 日
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
Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 22 日
編集済み: Engineer Batoor khan mummand 2020 年 10 月 22 日
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;
Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 22 日
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
Sudhakar Shinde
Sudhakar Shinde 2020 年 10 月 22 日
does this works:
% Get the averages over any and all hours of each day.
dailyAverages = splitapply(@mean, numbers>200, sequentialDays);
Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 22 日
hi:
it gives me an error of (' empty double column vector')
thanks
Sudhakar Shinde
Sudhakar Shinde 2020 年 10 月 22 日
編集済み: Sudhakar Shinde 2020 年 10 月 22 日
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);
Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 22 日
Done thank u so much dear from your helping and support.
Sudhakar Shinde
Sudhakar Shinde 2020 年 10 月 22 日
Welcome. glad to help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Import and Analysis についてさらに検索

製品

リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by