Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4282
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Graph plotting problem |
| Date | 2011-08-10 10:56 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j1to58$psg$1@smc.vnet.net> (permalink) |
| 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]
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Graph plotting problem "DaleJenk" <dale.jenkins8@deletegooglemail.com> - 2011-08-09 11:29 +0000 Re: Graph plotting problem Peter Pein <petsie@dordos.net> - 2011-08-10 10:56 +0000
csiph-web