フィルターのクリア

How to plot average monthly data from excel using matlab R2013a?

2 ビュー (過去 30 日間)
nsyn
nsyn 2016 年 4 月 16 日
コメント済み: Kuifeng 2016 年 4 月 17 日
Hello, I am trying to open data in excel file and then plot average monthly data. my code shown like this:
*filename ='Palembang.xlsx';
[num, txt, alldata]= xlsread(filename);
data = num(:,4);
jan = mean(data(7:361,:)); % raw data 7 until 361
feb = mean(data(362:844,:));
mar = mean(data(845:1201,:));
apr = mean(data(1202:1542,:));
may = mean(data(1543:1869,:));
jun = mean(data(1870:2261,:));
jul = mean(data(2262:2536,:));
aug = mean(data(2537:3051,:));
sep = mean(data(3052:3616,:));
oct = mean(data(3617:4297,:));
nov = mean(data(4298:4833,:));
dec = mean(data(4834:5273,:));
%get all the months of 2014
startdate = datenum('01-01-2014','dd-mm-yyyy');
enddate = datenum('31-12-2014','dd-mm-yyyy');
xdata = linspace(startdate,enddate,12);
ydata =
plot(xdata,ydata)
hold on
datetick('x','mmm','keepticks');
hold off*
in ydata it's still blank, because I dont know yet what command should I write there to plot the average data for each month? I hope somebody knows a better way to do it. thank you for everyone
  1 件のコメント
Kuifeng
Kuifeng 2016 年 4 月 17 日
%something like
MthMatrix = nan(31,12) %create the matrix
%Then find the location of 1st day of each month, and fill the columns respectively.
then I believe you can do the rest.

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

採用された回答

Kuifeng
Kuifeng 2016 年 4 月 16 日
ydata = [jan feb mar apr may jun ...
jul aug sep oct nov dec]; %it should work.
%other options, make a matrix of 12 columns representing each month
%fill empty date with NaN. use the function ydata = mean(matrix, 2)
  1 件のコメント
nsyn
nsyn 2016 年 4 月 17 日
thank you Kuifeng, it's work.. I want to try other options, like you mention above. can you explain more about the matrix that you mean?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by