For loop for wind speed analysis

5 ビュー (過去 30 日間)
Ben Hatrick
Ben Hatrick 2022 年 1 月 5 日
コメント済み: Ben Hatrick 2022 年 1 月 6 日
Hello, I am currently working on a data set from a wind turbine. I have calculated the values of wind speed and power output given as u_A & P_A respectively in the code below. I want to split the data into 25 sections that are 1 m/s wide and find the average wind speed and output power from 0m/s till 25m/s (cut-off speed of turbine). I know i need to iterate the process to do this but am not sure were to start. The code I have used so far is found below.
u_list = (u_lower <= u_A) & (u_A < u_upper);
u = u_A(u_list);
P = P_A(u_list);
This works as the wind speed and energy production vectors are paired with respect to their indices and so finding the postion of the relevant velocity will also give the power output. I am looking for a way to change the upper and lower bounds in steps of 1 until u_upper = 25 and find the mean and stanard deviation within each bound. Any help would be much appreciated!.
  1 件のコメント
dpb
dpb 2022 年 1 月 5 日
See
doc discretize % and friends
Also if you'll use a table object to hold the data,
doc groupsummary
will probably let you do all you wish in just a few lines of code.

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

採用された回答

Voss
Voss 2022 年 1 月 5 日
u_lower = 0:25;
N = numel(u_lower)-1;
u_mean = NaN(1,N);
u_std = NaN(1,N);
p_mean = NaN(1,N);
p_std = NaN(1,N);
for i = 1:N
u_list = (u_lower(i) <= u_A) & (u_A < u_lower(i+1));
if ~any(u_list)
continue
end
u = u_A(u_list);
P = P_A(u_list);
u_mean(i) = mean(u);
u_std(i) = std(u);
p_mean(i) = mean(P);
p_std(i) = std(P);
end
  1 件のコメント
Ben Hatrick
Ben Hatrick 2022 年 1 月 6 日
Works perectly thanks so much for your help!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by