MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Multiplying a constant to a matrix column

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16394] Re: [mg16251] Multiplying a constant to a matrix column
  • From: Mitch Stonehocker <derivado at campus.ccm.itesm.mx>
  • Date: Thu, 11 Mar 1999 02:16:57 -0500
  • References: <199903050541.AAA13659@smc.vnet.net.>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
I hope this helps.  First create a matrix
A1=Table[{n,n+1,n+2},{n,1,5}]
{{1,2,3},{2,3,4},{3,4,5},{4,5,6},{5,6,7}}

Second Identify which column you wish to apply your rule
ColChange=2;

Third apply the rule (in this example 2*column)
A2=Transpose[
      A[1] /. Transpose[A1][[ColChange]] \[Rule] 2 * Transpose[A1][[ColChange]]

{{1,2,3,4,5},{4,6,8,10,12},{3,4,5,6,7}}

Now you back to (a new) A1 with the change (2*column)
A1=Transpose[A2]
{{1,4,3},{2,6,4},{3,8,5},{4,10,6},{5,12,7}}

I hope that's the result your looking for.
Regards,
Mitch Stonehocker
Mexico City



Hyo Ahn wrote:

> Hi,
>
> I would like to multiply a constant number to a given column of an existing
> matrix in Mathematica and I am having a hard time.
>
> First, I have a 1000 x 3 matrix A.  There is no command that allow me to
> multiply a constant number to a specific column, so I extract three columns
> separately using
>
> A1 = A[Range[1,1000],Range[1,1]];
> A2 = A[Range[1,1000],Range[2,2]];
> A3 = A[Range[1,1000],Range[3,3]];
>
> fpr the first column and so on.  Then I multiply a constant to a extracted
> column which is a vector now.   Finally, I tried
>
> A4 = ColumnJoin[A1,A2,A3]
>
> but I found out that ColumnJoin command does not worked the way I expected
> it to be.
>
> Could anyone know a simple solution to this problem?
>
> Thanks.
>
> Hyo Ahn
> KAERI



  • Prev by Date: Re: MathLink Programming reference
  • Next by Date: Re: Position of element in a list
  • Previous by thread: Re: Multiplying a constant to a matrix column
  • Next by thread: Re: Multiplying a constant to a matrix column