0
|
2131 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
GROUPS:

# [?] Select and replace on a 2D lists of data?

Posted 7 years ago
 How do I select range of elements on a 2D lists of data and replace the selected elements with a specified range of values. For example if K = {{4, 6, 7, -8, 2, 1, 9, 6, 10, 1}, {2, 2, 3, 9, -10, 3, 4, 7, 8, 1}, {5, 4, 2, 1, 10, 8, 7, 3, -9, 5}}  I like to select elements in the range of (5 to 10) and range of (-5 to -10), replace all the selected with range of (1 to 3) and (-1 to -3) respectively.
4 Replies
Sort By:
Posted 7 years ago
 Strange how it duplicated your post under my name...What I posted was that you can certainly use Map[] to map a replacement function over your list with "rules" in it. or if your replacement is as simple as you indicate, you can just do: K /. {5-> 2, -5 -> -2} Regards
Posted 7 years ago
 How do I select and replace on a 2D lists of data?.
Posted 7 years ago
 I want to replace values higher than a specific number e.g 5 and -5, with specific values e.g replace 5 with 2 and -5 with -2.
Posted 7 years ago
 You need to give some examples. I don't understand what you are asking. For example, How do you know what to replace a value with if you are replacing 5 values in the range of 5 to 10 with 3 values in the range of 1 to 3?