For loop for wind speed analysis

3 views (last 30 days)
Ben Hatrick
Ben Hatrick on 5 Jan 2022
Commented: Ben Hatrick on 6 Jan 2022
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 Comment
dpb
dpb on 5 Jan 2022
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.

Sign in to comment.

Accepted Answer

Voss
Voss on 5 Jan 2022
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

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!