I am trying to sum every 5 rows of a column, Is my part of code right
instdec = (instdec_t+instdec_d)/2; startdec1 = (instdec >= 0.25*overalldec); startdec2=zeros(npts,1); while decpt==1 for j = 2:npts-4 startdec2(j) = sum(startdec1(j:j+4)); if startdec2(j)== 5 decpt=j-1; break end end
I keep getting wrong answers, the second row becomes 2, and everything else is zeros
I would appreciate any support since I am very new to matlab
No products are associated with this question.
Hi Jan and tom.
the purpose is to check if the numbers on every row exceed a certain value for a 5 successive rows.
so, the methodology I used is that if the condition of exceeding that certain number happens then generate 1, otherwise 0.
to check the of every five successive rows meet the condition, I want to sum every 5 rows and when the sum is 5 then I know that location and get its original value.
I can't really provide data tom. sorry for that and thanks for your help.