Re: Multiply a constant to a matrix column
- To: mathgroup at smc.vnet.net
- Subject: [mg16381] Re: [mg16266] Multiply a constant to a matrix column
- From: "Wolf, Hartmut" <hwolf at debis.com>
- Date: Thu, 11 Mar 1999 02:16:50 -0500
- Organization: debis Systemhaus
- References: <199903050541.AAA13716@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Hello Hyo Ahn
Hyo ahn schrieb:
>
> Hi,
>
> I would like to multiply a constant number to a certain 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 (let say I want to multiply
> 100 to the second column)...
---x---x---x---
Just to give you another variant for solution:
In[1]:= A=Table[a[i,j], {i,1,4},{j,1,3}]
Out[1]=
{{a[1,1],a[1,2],a[1,3]},{a[2,1],a[2,2],a[2,3]},
{a[3,1],a[3,2],a[3,3]},{a[4,1],a[4,2],a[4,3]}}
>To multiply a column
In[2]:= Map[MapAt[Times[Q,#]&,#,{2}]& , A]
Out[2]=
{{a[1,1],Q a[1,2],a[1,3]},{a[2,1],Q a[2,2],a[2,3]},
{a[3,1],Q a[3,2],a[3,3]},{a[4,1],Q a[4,2],a[4,3]}}
>To multiply a row
In[3]:= MapAt[Times[Q,#]&,A,{2}]
Out[3]=
{{a[1,1],a[1,2],a[1,3]},{Q a[2,1],Q a[2,2],Q a[2,3]},
{a[3,1],a[3,2],a[3,3]},{a[4,1],a[4,2],a[4,3]}}
---Hartmut
_________________________________________________________
Hartmut Wolf, debis Systemhaus, Darmstadt, Germany
- References:
- Multiply a constant to a matrix column
- From: heahn@nanum.kaeri.re.kr (Hyo ahn)
- Multiply a constant to a matrix column