[MATLAB] Write a function called hw4_problem1 that takes two inputs: a vector v and a positive integer scalar n. You do NOT need to check these assumptions. The function needs to find the n consecutive elements in v whose sum is the maximum. It needs to return the sum and the index of the first of these elements. If there are multiple such n consecutive elements in v, it returns the first one, i.e., the one with the smallest index. Here is an example run:
>> [total ind] = hw4_problem1([1 2 3 4 5 4 3 2 1],3)
total =
13
ind =
4
Please find the code below:

function [ s,index ] = hw4_problem1( v,n)
s=0;
index=0;
for i=1:length(v)-n
temp = sum(v(i:i+n-1));
if s<temp
s= temp;
index = i;
end
end
end
output:

[MATLAB] Write a function called hw4_problem1 that takes two inputs: a vector v and a positive...