Hello,
I guess my code is right but i get the above mentioned error. Someone please help me solve the problem….
I have attached the code below
function [summa , index] = max_sum(M,n) b=size(M);total = 0;comp = 0; if n>b(1,2) index = -1;summa = 0;return else for i = 1:b(1,2)-n+1 total = 0; for a = 0:n-1 total = total+M(i+a); end if total>comp comp = total;index = i; end end summa = comp; endend
Best Answer