B Homework 4 O CS 1103 M Settings - esm x 101 Chem101 Finding The A x 4 Ways to Cal x k2cro4 molar Pt Periodic Table x G agno3 molar x A brightspace.vanderbilt.edu/content/enforced/307117-2021F.1.CS.1103.01/HW4.pdf ES E : |2 / 2 | 100% +| 8 O CS 1103 3. Problems 1. Write a function called hw4_probleml 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 probleml ([1 2 3 45 4 3 2 1],3) total - 13 ind = 2. Write a function called hwd problem2 that takes a vector v as input. The function checks whether the elements of v are monotonically non-decreasing or not. In other words, any element of v must not be smaller than the previous element. The function returns a logical true if the condition holds and false otherwise. The function also returns a logical false if the input is not a vector (or scalar). 3. Write a function called hw4_problem3 that takes k, a positive integer scalar as an input (you do not need to check this). The function returns p, the smallest prime number smaller than 1000 such that p+k is also prime. If no such prime exists, the function returns 0. You may use the built-in functions primes and/or isprime. 4. Write a function called hw4_problem4 that computes a sum as defined below. The function returns the smallest n such that the sum is greater than the single input argument called 1imit. As a second output, the function also returns the corresponding sum. 1 1 234 1 S = = 1+5+ -+ -+... k=1 You are not allowed to use for loops. Here are a few examples: >> (n s) - hw4_problem4 (1) n = 2 1.500000000000000 >> (n s) - hw4_problem4 (2) 4 2.083333333333333 >> (n s] - hw4_problem4 (8) n - 1674 I hw4.p Show all 9:06 PM (DELL 10/31/2021

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

How do I do number 2 this is matlab 

B Homework 4
9 CS 1103
M Settings - esm x
101 Chem101
Finding The A X
wH 4 Ways to Calc X
G k2cro4 molar
Pt Periodic Table X
G agno3 molar
+
O X
A brightspace.vanderbilt.edu/content/enforced/307117-2021F.1.CS.1103.01/HW4.pdf
* ES
E
CS 1103
2 / 2
100%
+ |
3. Problems
1. 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 =
1
13
ind =
4
2. Write a function called hw4_problem2 that takes a vector v as input. The function checks whether the elements of v are
monotonically non-decreasing or not. In other words, any element of v must not be smaller than the previous element.
The function returns a logical true if the condition holds and false otherwise. The function also returns a logical false
if the input is not a vector (or scalar).
Write a function called hw4_problem3 that takes k, a positive integer scalar as an input (you do not need to check this).
The function returns p, the smallest prime number smaller than 1000 such that p+k is also prime. If no such prime
exists, the function returns 0. You may use the built-in functions primes and/or isprime.
3.
2
4. Write a function called hw4 problem4 that computes a sum as defined below. The function returns the smallest n such that the
sum is greater than the single input argument called limit. As a second output, the function also returns the corresponding sum.
n
1
1
1
+=+ -++
S =
= 1 +
2.
3
4
k=1
You are not allowed to use for loops. Here are a few examples:
>> [n s] = hw4_problem4 (1)
n =
2
S =
1.500000000000000
» [n s] = hw4_problem4 (2)
n =
S =
2.083333333333333
» [n s] = hw4_problem4 (8)
n =
1674
S =
hw4.p
Show all
9:06 PM
DELL
10/31/2021
...
...
II
Transcribed Image Text:B Homework 4 9 CS 1103 M Settings - esm x 101 Chem101 Finding The A X wH 4 Ways to Calc X G k2cro4 molar Pt Periodic Table X G agno3 molar + O X A brightspace.vanderbilt.edu/content/enforced/307117-2021F.1.CS.1103.01/HW4.pdf * ES E CS 1103 2 / 2 100% + | 3. Problems 1. 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 = 1 13 ind = 4 2. Write a function called hw4_problem2 that takes a vector v as input. The function checks whether the elements of v are monotonically non-decreasing or not. In other words, any element of v must not be smaller than the previous element. The function returns a logical true if the condition holds and false otherwise. The function also returns a logical false if the input is not a vector (or scalar). Write a function called hw4_problem3 that takes k, a positive integer scalar as an input (you do not need to check this). The function returns p, the smallest prime number smaller than 1000 such that p+k is also prime. If no such prime exists, the function returns 0. You may use the built-in functions primes and/or isprime. 3. 2 4. Write a function called hw4 problem4 that computes a sum as defined below. The function returns the smallest n such that the sum is greater than the single input argument called limit. As a second output, the function also returns the corresponding sum. n 1 1 1 +=+ -++ S = = 1 + 2. 3 4 k=1 You are not allowed to use for loops. Here are a few examples: >> [n s] = hw4_problem4 (1) n = 2 S = 1.500000000000000 » [n s] = hw4_problem4 (2) n = S = 2.083333333333333 » [n s] = hw4_problem4 (8) n = 1674 S = hw4.p Show all 9:06 PM DELL 10/31/2021 ... ... II
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY