Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Mathlab Task 1 Write your own function mfile that accepts two row vectors, A and B , as inputs and produces the following outputs .

Mathlab

Task 1

Write your own function mfile that accepts two row vectors, A and B, as inputs and produces the following outputs. Save your function mfile as task1.m

  • A scalar that gives the number of elements in B that are greater than the mean of the elements in A.
  • A column vector of all the prime numbers that lie between the minimum value in A and the maximum value in B.
  • A two element row vector in which the first element is the number of prime numbers between min(A) and max(B) that are also greater than the mean of the elements in A. The second element in this vector is the sum of these primes.

Next write a script mfile to test your function for the following cases. Save your script file as ScriptTask1.m. Be sure to assign all three outputs to target variables with unique descriptive names in each of the function calls. This practice is to ensure that all of your results are stored in the base workspace. Make sure to include help comments in your script mfile as well.

Test case 1: A = [12 9 3 2 25]; B = [1 6 20 4 5 15 12];

Answers for case 1 should be

out1 = 3 %There are 3 elements in B greater than the average of A which is 10.2.

out2 = [2 3 5 7 11 13 17 19] %These are the primes between min(A) = 2 and max(B) = 20.

out3 = [4 60] %Four of the primes in are greater than mean(A) and their sum is 60.

Test case 2: A = [3:3:99]; B = [4:4:44];

Test case 3: A = [100:-2:50]; B = [60:70];

Test case 4: make up your own

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions