Question: ( b ) Write a function ( m file ) takes an array and replaces and values outside of the lower and upper ranges by

(b) Write a function (m file) takes an array and replaces and values outside of the
lower and upper ranges by 0. For example, the function could be used to remove
any invalid examination grades, where a grade could be less than zero or greater
than 100. Make use of the vectorisation capabilities of MATLAB, and therefore a
loop should not be required for the solution. Here are sample calls, along with the
output that should be generated.
rng(100);
test = randi([-10110],4,5);
test_val = validate_data(test,0,100);
>> test
55-1061288
23459310
4171971688
92891510823
>> test_val
55061288
23459310
4171971688
928915023
[10 marks]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!