MATLAB: Sum up row values

sum rows

I have this program for finding the max precipitation for a 5 minute intervall. I was wondering if someone could help me find an alternative for the line
p_ny = p(row)+p(row-1)+p(row-2)+p(row-3)+p(row-4);
So when I want to find the maximum precipitation for longer time intervals i don't have to type in
p_ny = p(row) +.....+p(row-59);
for one hour…
Here is my full code:
clear all
data = load('samletmin');
ar = data(:,1);
mnd = data(:,2);
dag = data(:,3);
time = data(:,4);
min = data(:,5);
p = data(:,6);
[nrow,ncol] = size(data);
ny_p = [];
for row = 5:nrow
---> p_ny = p(row)+p(row-1)+p(row-2)+p(row-3)+p(row-4); <---
ny_p(end+1) = p_ny;
end
ny_p = ny_p';
[X,Y] = max(ny_p);

Best Answer

p_ny = sum(p(row-4:row));
Best wishes
Torsten.