Compare and replace elements in matrix
Compare and replace elements in matrix
(OP)
i have a matrix which has 16 columns and varying number of rows.. i
need to replace the elements ranging from -50 to 50 with zero and the
rest should remain the same.. i have coded for a single element
search and replace which is
[m, n] = size(Data);
for i = 1: m
for j = 1:n
if ( Data(i,j) == 1 )
Data(i,j) = 0;
end
end
end
but how do i do it for a range of -50 to 50 instead of a 1 in my
code.. could anyone help me out.. also please suggest me if there are
any matlab function which does this with out the use of the for
loops...
Regards,
capzos
need to replace the elements ranging from -50 to 50 with zero and the
rest should remain the same.. i have coded for a single element
search and replace which is
[m, n] = size(Data);
for i = 1: m
for j = 1:n
if ( Data(i,j) == 1 )
Data(i,j) = 0;
end
end
end
but how do i do it for a range of -50 to 50 instead of a 1 in my
code.. could anyone help me out.. also please suggest me if there are
any matlab function which does this with out the use of the for
loops...
Regards,
capzos





RE: Compare and replace elements in matrix
TTFN
RE: Compare and replace elements in matrix
i think i found the soln for this.. but help me in future
thanks
RE: Compare and replace elements in matrix
if ( Data(i,j) >= -50 AND Data(i,j) <= 50 )
Data(i,j) = 0;
Dan
dan@dtware.com
RE: Compare and replace elements in matrix