For loop for wind speed analysis

조회 수: 8 (최근 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 CenterFile Exchange에서 Wind Power에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by