View the step-by-step solution to:

Write a function that takes in a row vector. The function should return a row vector of the same size.

Write a function that takes in a row vector. The function should return a row vector of the same size. The value of result vector at a particular index should contain minimum value of input vector elements up to (and including) that index. If the input is not a row vector, throw an error.

You may not use any built in functions other than size, length, error, fprintf, disp, and zeros.

 

Example function call:

 

>> pracFunc([10, 5, 20, 3, 0])

ans = [10, 5, 5, 3, 0]


 

Next, write a script that tests your function. Create 3 test cases (3 function calls) where your function gets called with:

 

  1. [11, 2, -1, 5, -3]
  2. [-11, 2, 1, 5, 3]
  3. [ 5, 4, 3, 2, 3]

 

Display appropriate messages saying whether each test is passed (hopefully your function passes each test).

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question