# Creating a for loop that goes through 12 month data in sets of 2

8 ビュー (過去 30 日間)
Sebastian Sunny 2021 年 12 月 3 日

Hi guys,
Ive been trying to implement a for-loop to plot graphs from a set data with each plot having 2 months in it, so the first plot would have all values from jan to feb and 2nd would have all values from march till april.
I also have been to trying to make the sets of data into 2 lines where the first is the plots for data constiting of jan to jun and the second line being data from jul to dec.
Thank you, any guidance would be appreciated

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

### 採用された回答

Eric Sofen 2021 年 12 月 3 日
T.month = month(t.disc_TimeStamp);
tiledlayout(3,2)
for m = 1:2:12
monthMatch = any(T.month == [m m+1],2);
% or
% monthMatch = (T.month == m | T.month == m+1);
Tplot = T(monthMatch, :);
% polar plot
nexttile
polar(Tplot.mean_NacelleOrientation_Deg, Tplot.mean_WindSpeed_mps,'.')
end
This approach assumes you've just got one year of data (otherwise, you'll combine Jan-Feb 2019 and Jan-Feb 2020 into one plot). Then you would need multiple grouping variables - month and year.

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

### その他の回答 (1 件)

KSSV 2021 年 12 月 3 日
You can proceed like below.
thedates = datevec(T.(1)) ;
% plot for Jan and Feb by getting indices of them
idx = thedates(:,2)==1 | thedates(:,2)==2 ;
% plot third column
plot(T.(1)(idx),T.(3)(idx))
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Sebastian Sunny 2021 年 12 月 3 日
Thank you for the feedback however my task requires me to use implent a for loop strusture when plotting, i also am using polar plots for the task

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

### カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by