MathGroup Archive 2000

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

Search the Archive

RE: Q: Matrix Construction


Mathematica will always balk if you ask it to take a part of an expression
which has no such part. That is what you are asking it to do.

What is your objective here? Are you trying to deal with the parts of
vectors symbolically and then later fill in the values of the parts? This is
a common problem so I will show one way to do it.

This defines the symbolic components of two vectors:

{v1, v2} = Array[x, {2, 2}]
{{x[1, 1], x[1, 2]}, {x[2, 1], x[2, 2]}}

This is a set of substitution rules for a specific pair of vectors:

subrules = Thread[Flatten /@ ({v1, v2} ->
     {{1, 2}, {2, -3}})]
{x[1, 1] -> 1, x[1, 2] -> 2, x[2, 1] -> 2,
  x[2, 2] -> -3}

Now we can do calculations using the symbolic components and then substitute
the actual values. This calculates the projection of vector v1 in the
direction of vector v2.

% /. subrules

(x[1, 1]*x[2, 1] + x[1, 2]*x[2, 2])/
  (x[2, 1]^2 + x[2, 2]^2)

David Park
djmp at

> From: Christoph [mailto:scone at]
To: mathgroup at
>    hi,
> i would like to create a matrix like this
> {{x[1][[1]],x[1][[2]]},{x[2][[1]],x[2][[2]]}}
> i tried to do it like this
> Table[x[i][[j]],{i,2},{j,2}] and got some errormessages (partlength).
> How can i just create this table without evaluating it now. Later i
> will define some vectors x to be filled in.
> Greetngs
> 	Christoph

  • Prev by Date: Re: Re: Big trouble with Mathematica Code parsing -- Rant.
  • Next by Date: rules for Sign[_]^n
  • Previous by thread: Re: Q: Matrix Construction
  • Next by thread: Re: Q: Matrix Construction