How to pick the right month?

2 ビュー (過去 30 日間)
gjashta
gjashta 2019 年 4 月 30 日
コメント済み: gjashta 2019 年 5 月 5 日
The data file covered 13 years from 2003-2016.
But in the data there is no date just the values of prices and demand.
So, can you help me to write a simple code to pick the date,
for example the data of march for all the years?? Then how to calculate the mean and the std for each month?
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 5 月 1 日
It would have been better if you had left the information that the data file covered 13 years from 2003: that would have provided context for other people reading the question hoping to learn from it.
Remember that we are not providing free private consulting service: we volunteer so that everyone can learn from what we say, by reading the questions and answers both.
gjashta
gjashta 2019 年 5 月 1 日
Sorry for my mistake!

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 4 月 30 日
Price = Data1(:,1);
Demand = Data1(:,2);
tv = (datetime([2003,1,1]):datetime([2015,12,31])).';
[Y,M,D] = ymd(tv);
DT = timetable(Price, Demand, Y, M, D, 'RowTimes', tv);
Now you can do tests such as
MarchData = DT(DT.M==3,:);
and you can also use timerange() selectors, https://www.mathworks.com/help/matlab/ref/timerange.html
and you can also do calculations such as
retime(DT, 'monthly', 'sum')
  4 件のコメント
gjashta
gjashta 2019 年 5 月 1 日
Thank you!
gjashta
gjashta 2019 年 5 月 5 日
How can I substract the mean of march for each year from the daily demand of march? Two vectors with defferent length.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by