Question: 1 2 3 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

 1 2 3 Write a function called as find_max_of_sums which will

1

take a row vector (rV) of numbers and a positive integer (PN)

2

as input arguments. The duty of the function will be finding the

3

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. "ON" can be larger than the number of elements if "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; Write a function called as find_max_of_sums which will take a row vector (TV) of numbers and a positive integer (PN) as input arguments. The duty of the function will be finding 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; 1) first one will be the sum o 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 if "V", in this case the function will 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 = 2 1 11 16 19 3 11 9 0 7 3 16 6 11 3 12 5 13 14 15 >> (sumofElements indexofFirst] = find_max_of_sums (testVector, 3) sumOfElements = 46 indexofFirst = 3 >> testVector = [3 4 5 6 6 5 4 3 5 5 1]; >> [sumofElements indexofFirst] = find_max_of_sums (test vector, 3) sumOfElements - 17 >> testVector = [3 4 5 6 6 5 4 3 5 5 1]; >> (sumo Elements indexofFirst] = find_max_of_sums (testvector, 3) sumOfElements = 17 indexofFirst = 3 >> testVector = [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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!