In cycling, a power meter is an indispensable tool to record power output (in Watts) and measure fitness gains and performance metrics. When analyzing the data though, many different workouts can yield approximately the same average power, despite major differences between workouts (e.g., a long steady effort vs. sprints or intervals). Normalized power (NP) is a method to measure the effect of more intense efforts on the overall workout. NP is calculated by the following four steps (from Training and Racing with a Power Meter by Allen and Coggan):
You will be provided with the 30-second rolling average power data set (vector). Write a function to return the average power (using the rolling average data) and the normalized power using steps 2–4 above. Round the values to the nearest integer.
I don't understand what I'm looking at, Ive attempted to add the code from a solution, but it seems like I'm missing something crutial...
function [P_avg,NP] = cycling_norm_power(power)
P_avg = 0;
NP = 0;
%% steady
power = 200*ones(1,3600);
P_avg_corr = 200;
NP_corr = 200;
[P_avg,NP] = cycling_norm_power(power);
assert(isequal(P_avg_corr,P_avg))
assert(isequal(NP_corr,NP))
??????????? really? 4 correct and 5 not?
Same problem as noted in the other comment. You get the correct P_avg here but not NP because the sprint is so short that the 30-second rolling average (applied twice) is rounded to the same answer. Unrounded P_avg answers for this routine and the correct routine are 131.3638 and 131.1111, respectively. Given that answers are being rounded, it may look wrong since the P_avg calculation appears to be right (due to rounding) while NP was wrong when both were actually wrong.
Maybe I'm wrong, but for sure the results in test 4 and 5 is NOT CORRECT
Note in the last paragraph of the explanation: "You will be provided with the 30-second rolling average power data set (vector)." In essence, your solution is calculating the 30-second rolling average of a 30-second rolling average data set.
13756 Solvers
Find the sum of the elements in the "second" diagonal
876 Solvers
Getting the absolute index from a matrix
176 Solvers
Replace multiples of 5 with NaN
279 Solvers
07 - Common functions and indexing 2
253 Solvers