How to prepare extract monthly Data from a group of data?

1 回表示 (過去 30 日間)
Rahul Verma
Rahul Verma 2023 年 1 月 24 日
コメント済み: Rahul Verma 2023 年 1 月 24 日
I have an excel file, containing monthly data of several years column-wise. Now i have to extract the data for perticular month (say February month from all the years). I want to write a code which can extract the data in aforementioned manner.
I have attached the excel file for better understanding. Descroption of data: The excel file contains years, months and data values. First column is year (1950-2022), second column- respective months and thrird column has values.
Now i want to extract the February month data from all the years. How can i do it?

採用された回答

VBBV
VBBV 2023 年 1 月 24 日
A = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1272440/AO_1950_2022.xlsx');
A.Properties.VariableNames = {'Year','Month','Data'};
idx=A.Month == 2;
AllFebData = [A.Year(idx) A.Data(idx)]
AllFebData = 73×2
1.0e+03 * 1.9500 0.0006 1.9510 -0.0004 1.9520 -0.0017 1.9530 -0.0002 1.9540 -0.0002 1.9550 -0.0015 1.9560 -0.0020 1.9570 -0.0015 1.9580 -0.0022 1.9590 0.0025
  1 件のコメント
Rahul Verma
Rahul Verma 2023 年 1 月 24 日
Thanks a lot, it is very helpful.

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

その他の回答 (1 件)

Arif Hoq
Arif Hoq 2023 年 1 月 24 日
a=table2array(readtable("AO_1950_2022.xlsx"));
b=a(:,2)==2;
febmonth=a(b,[1 3]);

カテゴリ

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