[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: S: Example
From: |
niles |
Subject: |
Re: S: Example |
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.