Groups | Search | Server Info | Login | Register
Groups > comp.soft-sys.math.mathematica > #16853
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: boolean indexing for subset reassignment |
| Date | 2014-04-26 06:07 +0000 |
| Message-ID | <ljfifb$guh$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
On 4/25/14 at 12:44 AM, alan.isaac@gmail.com (Alan) wrote:
>Thanks for taking a stab at this, but you have not described
>comparable functionality. Most importantly, you are not changing
>the list `b` in place.
I don't understand why you do not see what I had posted as
comparable since it outputs the same result as described. If
your objection is simply I did not modify the original array,
that is trivial to change. Where I had posted
m = b Unitize@Clip[a, {1, 15}, {0, 0}]
this could be done as:
b = b Unitize@Clip[a, {1, 15}, {0, 0}]
which would change the original array.
In either case, what is returned is an array containing the
elements of b except those that exceed 15 which are replaced
with 0. That is:
In[18]:= a = RandomInteger[{1, 20}, {4, 3}]
Out[18]= {{8, 9, 11}, {16, 7, 20}, {4, 6, 3}, {12, 13, 16}}
In[19]:= b = RandomReal[1, {4, 3}];
b = b Unitize@Clip[a, {1, 15}, {0, 0}];
In[21]:= a Unitize[b]
Out[21]= {{8, 9, 11}, {0, 7, 0}, {4, 6, 3}, {12, 13, 0}}
showing b now has a 0 where a has a value greater than 15
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar
Re: boolean indexing for subset reassignment Bill Rowe <readnews@sbcglobal.net> - 2014-04-26 06:07 +0000
csiph-web