MathGroup Archive 2013

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

Search the Archive

Re: RE: Re: Animate Command and Vector Reference

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131440] Re: RE: Re: Animate Command and Vector Reference
  • From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
  • Date: Sat, 6 Jul 2013 05:04:07 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <ffd0249e8f04425086acc881aa14ddff@DBXPR07MB095.eurprd07.prod.outlook.com>

Thank you, Bob, for the answer.

After some experimenting I see that this:

Animate[
 sub[x_] := {{x, 1}, {x^2, 1}};
 Graphics[{Line[{{0, 0}, sub[a][[1]]}]}], {a, -1, 1}]

And this:

sub[x_] := {{x, 1}, {x^2, 1}};
Animate[
 sub[x_] := {{x, 1}, {x^2, 1}};
 Graphics[{Line[{{0, 0}, sub[a][[1]]}]}], {a, -1, 1}]

indeed do not work, as it is reported initially in the William's post. Though it should.  This, however, works:

Animate[
 sub1[x_] := {{x, 1}, {x^2, 1}};
 Graphics[{Line[{{0, 0}, sub1[a][[1]]}]}], {a, -1, 1}]

This also works:

sub1[x_] := {{x, 1}, {x^2, 1}};

Animate[
 Graphics[{Line[{{0, 0}, sub1[a][[1]]}]}], {a, -1, 1}]

The latter is the construct that William used. We may also write is in such a way

sub1[a_] := {{a, 1}, {a^2, 1}};
Animate[
 Graphics[{Line[{{0, 0}, sub1[a][[1]]}]}], {a, -1, 1}]

This plays, of course, no role, but this is already exactly the William's construct. It works. The only difference is that in the example that does not work the function has the name "sub" and in the working example its name is "sub1".

Strange, is it not? A bug?

Best, Alexei


Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at iee.lu


From: Bob Hanlon [mailto:hanlonr357 at gmail.com]
Sent: Friday, July 05, 2013 1:45 PM
To: Alexei Boulbitch
Cc: mathgroup at smc.vnet.net
Subject: [mg131440] Re: Re: Animate Command and Vector Reference

The argument of the function isn't defined until it is called, so a call within Animate puts the argument within the Animate's scope.

sub[a_] := {{a, 1}, {a^2, 1}};

Animate[Graphics[{Line[{{0, 0}, sub[a][[1]]}]}], {a, -1, 1}]


Bob Hanlon

On Fri, Jul 5, 2013 at 3:05 AM, Alexei Boulbitch <Alexei.Boulbitch at iee.lu> wrote:
This is a scoping issue. The a used in the Animate iterator is local to the
Animate.


sub = {{a, 1}, {a^2, 1}};

OK, Bob, and  why this

sub[a_]:={{a,1},{a^2,1}};


Animate[Graphics[{Line[{{0,0},sub[a][[1]]/.a->aa}]}],{{aa,-1,"a"},-1,1}]

In version 6 this worked perfectly. What happened since?

Best regards, Alexei



This is a scoping issue. The a used in the Animate iterator is local to the
Animate.


sub = {{a, 1}, {a^2, 1}};


Animate[
 Graphics[{
   Line[{{0, 0}, sub[[1]] /. a -> aa}]
   }],
 {{aa, -1, "a"}, -1, 1}]



Bob Hanlon

On Wed, Jul 3, 2013 at 4:59 AM, William Dickinson <
william.dickinson.0718 at gmail.com> wrote:

> I'm new to Mathematica and I want to create some animations. I tried
> something like this:
>
> sub = {{a, 1}, {a^2, 1}}
> Animate[Graphics[{Line[{{0, 0}, sub[[1]]}]}], {a, -1, 1}]
>
> and Mathematica give me an error. This error ( Coordinate {a, 1} should be
> a pair of numbers, or a Scaled or Offset form.) is not helpful.
>
> I know that I can fix this by changing sub[[1]] to {a,1}, but this is not
> a great solution. I have several places in the actual Animate command that
> use sub[[1]] (some in conjunction with a Table command) and it would be
> painful to do all of the replacing and rewriting. How can I make something
> like this work?
>
> I suspect that I'm missing something simple....
>
>
> Thanks in advance!
>
> Will
>
>
>
Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at iee.lu







  • Prev by Date: User-defined Probability Mass Function
  • Next by Date: how to write ParallelSubmit in a Do loop? trying to use up all CPU
  • Previous by thread: Re: RE: Re: Animate Command and Vector Reference
  • Next by thread: Multiple Line coloring and Dashing in ListPlot