Question: Write a function called as find_max_of_sums which will take a row vector (rV) of numbers and a positive integer (pN) as input arguments. The duty
Write a function called as find_max_of_sums which will take a row vector (rV) of numbers and a positive integer (pN) as input arguments. The duty of the function will be finding the "pN" consecutive elements of rV whose sum is the largest. If there exists multiple sequences that satisfy this, the function will return the first one. There will be two output arguments; i) first one will be the sum of "pN" elements (sumOfElements) and ii) as the second, the index (indexOfFirst) of first element of the "pN" consucutive ones. "pN" can be larger than the number of elements f "rV", in this case the function will return 0 as the sum and -1 as the index.
Example usages of the function is given below;
Please upload your written function as a m.file (if .m file type is not supported, please upload your function as a .txt file).

>> testVector = round (rand(1,20) 20) test Vector = 11 16 19 3 11 907 3 16 6 11 3 12 5 13 14 15 >> [sumo Elements indexofFirst] = find_max_of_sums (test Vector, 3) sumofElements - 46 indexofFirst- >> testVector = [3 4 5 6 6 5 4 3 5 5 1]; >> (sumofElements indexofFirst] = find_max_of_sums (testVector, 3) sumOfElements = 17 indexofFirst = 3 >> test Vector = [3 4 5 6 6 5 4 3 5 5 1]; >> (sumofElements indexofFirst] = find_max_of_sums (testVector, 13) sumOfElements = 0 indexOfFirst = -1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
