In MAtlab write a function such that function newX = myBandPass(X, low, high) a.
ID: 3697369 • Letter: I
Question
In MAtlab write a function such that
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 CASE: >> A = [176.2360 171.0640 115.8960 162.4440; 207.2680 179.6840 0 0; 233.1280 190.0280 145.2040 146.9280; 248.6440 177.9600 181.4080 164.1680];
>> myBandPass(A, 175, 245)
ans = 176.2360 0 207.2680 179.6840 233.1280 190.0280 0 0 0 0 0 0 0 177.9600 181.4080 0
Explanation / Answer
function newX = myBandPass(X, low, high)
for i=1:size(X,1)
for j=1:size(X,2)
while (X(i,j)>high||X(i,j)<low)
newx(i,j)=0;
end
newx(i,j) = X(i,j);
end
end
end
newx
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.