Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called as find_max_of_sums which will take a row vector (V) of numbers and a positive integer (PN) as input arguments. The duty

image text in transcribed

Write a function called as find_max_of_sums which will take a row vector (V) 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 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; Please upload your written function as a m.file (if.m file type is not supported, please upload your function as a .txt file). >> test Vector = round (rand(1,20) 20) test Vector = 11 16 19 3 11 9 16 6 11 3 12 5 13 14 15 >> (sumo Elements indexofFirst] = find_max_of_sums (test Vector, 3) sumofElements - 46 indexoffirst = 3 >> 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain strong and weak atoms with examples.

Answered: 1 week ago

Question

Explain the alkaline nature of aqueous solution of making soda.

Answered: 1 week ago

Question

Comment on the pH value of lattice solutions of salts.

Answered: 1 week ago