Divide by every N rows

2 views (last 30 days)
david crowley
david crowley on 8 Aug 2021
Answered: KSSV on 8 Aug 2021
I am trying to perform the following calculation, but every 52 rows the denominator needs to change from (1,1) to (52,1) then (104,1) etc.
Can someone please assist?
rAPf(i,:) = ((tickPf(i,1) / tickPf(1,1))-1)*100;

Accepted Answer

KSSV
KSSV on 8 Aug 2021
t = 1 ;
for i = 1:n % n should be your last index
if mod(i,52) == 0
t = i ;
end
rAPf(i,:) = ((tickPf(i,1) / tickPf(t,1))-1)*100;
end

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!