indexing of starting element of sum

1 view (last 30 days)
asad jaffar
asad jaffar on 3 Apr 2019
Commented: Jan on 5 Apr 2019
function [summa,index=nba_aj(b,n)
if n>s
elseif n<=s
what should i do after this for index finding
% here i want to know the index
can you guys help me the required answer is
summa=13,index=4 b=[1 2 3 4 5 4 3 2 1] n=3
summa=5,index-5 b=[1 2 3 4 5 4 3 2 1] n=1
Jan on 5 Apr 2019
As Walter has said already: This topic has been discussed already and you find a working solution there also. All you need is reading the documentation of movsum:
doc movsum
and to learn, why you have to ignore the marginal elements by setting 'EndPoints' to 'discard'. In addition you have to use the 2nd output of max.
Pleae note that posting working solution of homework questions is not really useful.

Sign in to comment.

Answers (0)


Community Treasure Hunt

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

Start Hunting!