Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Thread::tdlen: Objects of unequal length in

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127766] Re: Thread::tdlen: Objects of unequal length in
  • From: Sseziwa Mukasa <mukasa at gmail.com>
  • Date: Mon, 20 Aug 2012 21:29:03 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20120820081407.058F0681E@smc.vnet.net>

The {} indicate a list, but lists can be nested so a structure of the 
form {{...}} is a list of length one whose first element is another 
list.  I'm not sure what you are after with the MapThread[Mean, 
Sequence[{{testdata}}]] expression, my guess is you're computing the 
mean along the rows of an array.  Assuming your data is in a 2D array 
then Last[testdata] is the last row of your data and what you expect is 
the number of columns (length of last row) to be the same as the number 
of computed means.

Assuming you want the means along the rows I would have done: 
Mean/@Transpose[testdata] (/@ is the infix form of Map so this is 
equivalent to Map[Mean,Transpose[testdata]]) which is probably easier to 
interpret.  Otherwise, just take the first element of the result of your 
MapThread expression: First[MapThread[Mean, Sequence[{{testdata}}]]] 
(alternatively MapThread[Mean, Sequence[{{testdata}}]][[1]] or 
Last[MapThread[Mean, Sequence[{{testdata}}]]]).

Regards,
	Sseziwa

On Aug 20, 2012, at 4:14 AM, Aaron wrote:

> I'm new to Mathematica and trying to run rebuild some programs from 
other systems in Mathematica.  I'm operating on large data lists and 
receiving the unequal length error.  However, if I simply paste the 
output without the extra curly bracket into an operation, everything 
works.  Obviously, copying and pasting wont work for functions... How 
can I get around this?
>
> Below are the functions I'm using to generate two lists from a single 
dataset:
>
> ln[13]:= MapThread[Mean, Sequence[{{testdata}}]]
> Out[13]= {{15.0059, 14.9897, 15.0248,....}}
>
> ln[14]:= Last[testdata]
> Out[14]= {14.9602, 14.8624, 15.3364, 15.0231,....}
>
> When I run Length on each of the outputs, I receive the proper number 
of datapoints for the Last function but receive an output of "1" for the 
Mean function.  If I paste the output with only 1 "{" though and run 
Length, I receive the proper output.
>
> I know this must be simple but I'm stuck.
>




  • Prev by Date: Re: Thread::tdlen: Objects of unequal length in
  • Next by Date: Re: How to make fitting code using NDSolve?
  • Previous by thread: Re: Thread::tdlen: Objects of unequal length in
  • Next by thread: Re: Thread::tdlen: Objects of unequal length in