In article <87zk3fc3wv.fsf@merciadriluca-station.MERCIADRILUCA>, Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hello, > > I've got a string, say str. This string contains only digits; for > example, 1456823. > > I also have two vectors: > 1) a row vector whose elements are the ones that need to be replaced > 2) a row vector whose elements are the ones that need to replace. > > For example, if I want to replace every `4' and `5' by `7' and `4', > respectively, in the original string, that means '1456823' becomes > '1746823'.
Just use a lookup table:
lut = char(1:255); lut('45') = '74'; % the substitutions to be made lut('1456823') ans = 1746823
-- Doug Schwarz dmschwarz&ieee,org Make obvious changes to get real email address.