Exercise 6.6: IF loop

Make a function file of the following form:

function b = replace(a)

in which all elements of a column greater than 5 are replaced by 0. Do this by without using the command find.

(HINT: Use the commands >> if and >> for)
a)
Work out the problem on paper.
b)
Write the m-file in MATLAB.
c)
Test the function file with the column [1;2;3;4;5;6;7] and, if necessary, debug the file,



Previous      Next      Up      Answer


Esteur 2010-03-22