MathGroup Archive 2011

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

Search the Archive

Re: Graph plotting problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120801] Re: Graph plotting problem
  • From: Peter Pein <petsie at dordos.net>
  • Date: Wed, 10 Aug 2011 06:48:39 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j1r5nk$fkp$1@smc.vnet.net>

Hi,

there are (at least) two issues:

1.) if you assign soln (or x1,x2,x3) a value inside a plotting command,
thiese variables will have got constant values after execution of Animate.

2.) you defined x1,x2,x3 as expressions, not functions.

The following works here:

m = 1.; b1 = 0.1; b2 = 0.1; b3 = 0.1;
soln = {x1, x2, x3} = c = Chop[b1*Cos[t]*{1, 0, -1} +
    b2*Cos[Sqrt[2 + Sqrt[2.]]*t]*{1, -Sqrt[2.], 1} +
    b3*Cos[Sqrt[2 - Sqrt[2.]]*t]*{1, Sqrt[2.], 1}];

Animate[Evaluate[Graphics[{Black,
  Line[{{0, 0}, {1, x1}, {2, x2}, {3, x3}, {4, 0}}], Red,
  Table[Disk[{i, soln[[i]]}, 0.1*Sqrt[m]], {i, 3}]},
  PlotRange -> {{0, 4}, {-1, 1}},
  Frame -> True, ImageSize -> {400, 250}]], {t, 0, 2*Pi, Pi/10}]

disp = Plot[Evaluate[soln], {t, 0, 2*Pi},
   ImageSize -> {200, 150},
   AxesLabel -> {Row[{"time ", Style["t", Italic]}], "displacement"},
   ImagePadding -> {{35, 35}, {10, 20}},
   AspectRatio -> Automatic (*3/4 ?*)]


hth,
Peter

Am 09.08.2011 13:29, schrieb DaleJenk:
> I'm trying to get a graph of displacement versus time but only the axes 
> appear. Thanks for any help.
> 
> Animate[m = 1.0;
>  b1 = .1;
>  b2 = .1;
>  b3 = .1;
>  soln = {x1, x2, x3} =
>    c = b1*Cos[t]*{1, 0, -1} +
>      b2*Cos[Sqrt[(2 + Sqrt[2])]*t]*{1, -Sqrt[2], 1} +
>      b3*Cos[Sqrt[(2 - Sqrt[2])]*t]*{1, Sqrt[2], 1};
>  balls = Graphics[{Black,
>     Line[{{0, 0}, {1, x1}, {2, x2}, {3, x3}, {4, 0}}],
>     Red, {Disk[{1, x1}, .1 Sqrt[m]], Disk[{2, x2}, .1 Sqrt[m]],
>      Disk[{3, x3}, .1 Sqrt[m]]}}, PlotRange -> {{0, 4}, {-1, 1}},
>    Frame -> True, ImageSize -> {400, 250}], {t, 0, 2 Pi}]
> disp = Plot[
>   Evaluate[{x1[t], x2[t], x3[t]}, {t, 0, 2 Pi},
>    ImageSize -> {200, 150},
>    AxesLabel -> {Row[{"time ", Style["t", Italic]}], "displacement"},
>    ImagePadding -> {{35, 35}, {10, 20}}], AspectRatio -> Automatic] 
> 
> 





  • Prev by Date: Re: Flow chart/block diagram for StyleSheets?
  • Next by Date: Re: Workbench not updated for version 8?
  • Previous by thread: Graph plotting problem
  • Next by thread: Workbench not updated for version 8?