Hello,
I'm trying to build a function that would read all the elements in a column matrix "a" then find the same value in column matrix "b" read the exact row and lastly sum all rows from exact row to exact row-30, and make it save all the answers in a new matrix.
This is what I have so far, but something is wrong.
function [psum, nsum] = datac (a, b, c) lngth=length(a); for i=1:lngth eyear=a(i, 1); row=find(b(:,1)==eyear); row2=row-30; psum(1,i)=sum(c(row2:row, 1) >0); nsum(1,i)=sum(c(row2:row, 1) <0);end
Best Answer