Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Matlab help with the following function please: function newX = myBandPass(X, lo

ID: 3695768 • Letter: M

Question

Matlab help with the following function please:

function newX = myBandPass(X, low, high)

a. INPUTS:

i. A 2D matrix X

ii. A low threshold, low. All values in newX must be greater than this.

iii. A high threshold, high. All values in newX must be less than this.

b. FUNCTIONALITY:

i. This function reads all elements of a matrix X, and sets them equal to zero if they are lower than low or higher than high.

c. OUTPUTS:

i. newX: The matrix X after zeroing out elements below low and above high.

d, TEST CASES:

>>A= [176.2360 171.0640 115.8960 162.4440; 207.2680 179.6840 233.1280 190.0280 145.2040 146.9280; 248.6440 177.9600 181.4080164.1680]; >>myBandPass (A, 175, 245) ans = 176.2360 207.2680 179.6840 233.1280 190.0280 0 0 0 0 177.9600 181.4080 0 0 0 0 0

Explanation / Answer

Answer for Question:

This below matlab script will replace the high and low values of given vector with zeros

A = [176.2360 171.0640 115.8660 162.4440
   207.2680 179.6840 0 0
   233.1280 190.0280 145.2040 146.9280
   248.6440 177.9600 181.4080 164.16080]

function newX = myBandPass(A, 175, 245)

   for i = 1: length(A)
       if A[i] < 175 then
           A[i] = 0
       else if A[i] > 245 then
           A[i] = 0     
       end
   end  
end

disp(A)