Post Reply 
Apply function to elements of a matrix column
08-30-2015, 10:54 AM (This post was last modified: 08-30-2015 10:55 AM by DrD.)
Post: #1
Apply function to elements of a matrix column
Replace column 5, element by element, with its absolute value:

M0:=[[1,1,0,1,2,1,0,0],[1,2,1,2,-5,0,0,1],[1,3,2,3,-6,0,0,1],[1,4,3,0,-3,0,0,1],[2,1,3,2,-6,0,0,1],[2,2,2,4,-2,0,0,1],[2,3,4,5,-5,0,0,1],[2,4,5,3,4,1,0,0],[3,1,5,4,5,0,0,1],[3,2,4,6,-2,0,0,1],[3,3,6,7,-8,0,0,1],[3,4,7,5,-8,1,0,0]];

desired result:

M0:=[[1,1,0,1,2,1,0,0],[1,2,1,2,5,0,0,1],[1,3,2,3,6,0,0,1],[1,4,3,0,3,0,0,1],[2,1,3,2,6,0,0,1],[2,2,2,4,2,0,0,1],[2,3,4,5,5,0,0,1],[2,4,5,3,4,1,0,0],[3,1,5,4,5,0,0,1],[3,2,4,6,2,0,0,1],[3,3,6,7,8,0,0,1],[3,4,7,5,8,1,0,0]];

This has been my best success, but is there a simpler way to apply a function to the elements of a column (or row)?:

[CAS]
M0(-5):=apply((x)->ABS(x),M0(-5));

-Dale-
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Apply function to elements of a matrix column - DrD - 08-30-2015 10:54 AM



User(s) browsing this thread: