From help-octave-request at che dot utexas dot edu Tue Jul 18 17:06:40 1995 Subject: Re: S: Example From: niles at gsfc dot nasa dot gov To: Nils Naumann Cc: help-octave at che dot utexas dot edu, niles@gsfc.nasa.gov Date: Tue, 18 Jul 95 13:06:31 -0400 >sorry, if this is a to stupid question. But I have red the manual and >played around a long time and I can't find a solution, except two for >loops, which will be really slow. >Doe's anyone have an example for changing elements of a matrix which >match a special condition? I will change all members of a matrix which are >lower than the value x to the value y. Here ya go... ------------------ function out = limit(matrix, x, y) % Usage out = limit(matrix, x, y) % % It will change all members of a matrix which are % lower than the value x to the value y. % By Rick Niles 7/18/95 z = matrix < x out = !z.*matrix + z*y; ------------------------ Hope this helps... it's actually not worthy of being a separate function, because of it's short length, but... Rick Niles.