Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtracting values from a matrix 1

Status
Not open for further replies.

hill007

Technical User
Mar 9, 2004
60
US
I am trying to subtract a value of 25 from the cells of a matrix.
Example:

2 3 6 9 12
-3 4 7 -2 -6
3 10 4 8 14

After subtracting 25 from the cells of the above matrix, it should be:

-23 -22 -19 -16 -13
-28 -21 -18 -27 -31
-22 -15 -21 -17 -11

How would I do this in awk95. Any help is always appreciated.
 
matrix.awk
Code:
{for(i=1;i<=NF;++i)$i-=25;print}
awk95 -f matrix.awk Matrix > newMatrix

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top