Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: problem of syntax.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104366] Re: problem of syntax.
  • From: Peter Breitfeld <phbrf at t-online.de>
  • Date: Thu, 29 Oct 2009 02:57:21 -0500 (EST)
  • References: <hc91nu$e3r$1@smc.vnet.net>

micmac wrote:

> Hello everyone,
>
> For some reasons, I have a matrix where each element is itself another
> matrix of size one.
> How can I transform that in a normal matrix where each element is just the
> value ?
>
> I am very confused with mathematica syntax.
>
> thanks,
>
> Julien
>

Suppose, you have the matrix

mat={{{1}, {2}}, {{3}, {4}}}

The Elements {1}, {2}, {3} and {4} are now on Level -2, as you can see
using TreeForm[mat].

Then use Replace on this Level to change the lists to their values:

Replace[mat,List[x_]->x, {-2}]

Out= {{1, 2}, {3, 4}}
-- 
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de


  • Prev by Date: Re: Re: old vs new(V7) BarChart3D
  • Next by Date: ToExpression[..,TexForm] does not seem to work on some Latex commands?
  • Previous by thread: Re: problem of syntax.
  • Next by thread: Re: problem of syntax.