introduction to programming with matlab - Vanderbilt University week-7 assignment 4 solutions

 Lesson 6 Wrap-Up


These solutions are for reference only.

It is recommended that you should solve the assignment and quiz by yourself honestly then only it makes sense to complete the course.

but if you cant figure out some part of it than you can refer these solutions

make sure you understand the solution  

dont just copy paste it

-----------------------------------------

function [summa, index] = max_sum(v, n)

    [~, len] = size(v);

    summa = -inf;

    if n > len

        summa = 0;

    end

    index = -1;

    for i = 1:(len - n + 1)

        s = sum(v(i : i + n - 1));

        if s > summa

            summa = s;

            index = i;

        end

    end

end

main course : https://www.coursera.org/learn/matlab

No comments

darkmode