Re: Parametric Plot Again
- To: mathgroup at smc.vnet.net
- Subject: [mg27138] Re: Parametric Plot Again
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Wed, 7 Feb 2001 02:12:44 -0500 (EST)
- References: <4Xnf6.3581$l32.32692@ralph.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Winston, I should have been more explicit. What you need is xd[t_] = x1[t] /. pend[[1]]; xdd[t_]= x1'[t] /. pend[[1]]; xr[t_] = x2[t] /. pend[[1]]; xrd[t_]= x2'[t] /. pend[[1]]; You see, pend is {{ x1 -> InterpolatingFunction[{{0., 5000.}}, "<>"], x2 -> InterpolatingFunction[{{0., 5000.}}, "<>"] }} and pend[[1]] is { x1 -> InterpolatingFunction[{{0., 5000.}}, "<>"], x2 -> InterpolatingFunction[{{0., 5000.}}, "<>"] } Regards, -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Winston Garira" <uceswga at ucl.ac.uk> wrote in message news:4Xnf6.3581$l32.32692 at ralph.vnet.net... > Hi Allan, > > Thank for replying to my request. I have tried to make the change that you > recommended by making the following changes: > > xd[t_] = x1[t] /. pend[[1]]; > xdd[t_]= x1'[t] /. pend[[2]]; > xr[t_] = x2[t] /. pend[[3]]; > xrd[t_]= x2'[t] /. pend[[4]]; > > But still the ParametricPlot[{xd[t], xdd[t]}, {t,0,100}]; > > does not work. Could it be that I misunderstood the change that you > recommended? > > Winston > > > > > I am trying to solve a system of two coupled pendulums using the NDSolve. > > > command. If I replace the Plot[{xd[t],xr[t]},{t,0,100}] with > > > ParametricPlot[{xd[t],xr[t]},{t,0,100}] it does not work. Can someone tell > > > me why the ParametricPlot command does not work in this case. I need to > > > make parametric plots for this system. > > > > > > Thanking you in annticipation > > > > > > Winston > > > > > > > > > Pends[init1_, init2_, time_, k_, {c_, w_, p_}]:= > > > Module[{}, > > > pend=NDSolve[{x1''[t]+ c x1'[t]+ p Sin[x1[t]]==k(x2[t]-x1[t]), > > > x2''[t]+ c x2'[t]+ p Sin[x2[t]]==k(x1[t]-x2[t]), > > > x1[0]==init1[[1]], x1'[0]==init1[[2]], > > > x2[0]==init2[[1]], x2'[0]==init2[[2]]}, > > > {x1, x2}, > > > {t,0,time}, MaxSteps->200000]; > > > xd[t_] := Evaluate[x1[t] /. pend]; > > > xdd[t_]:= Evaluate[x1'[t] /. pend]; > > > xr[t_] := Evaluate[x2[t] /. pend]; > > > xrd[t_]:= Evaluate[x2'[t] /. pend]; > > > ]; > > > > > > > > > c=0.1; w=0.5; p=1.9; > > > > > > Pends[{1.57,0}, {-1.57,0}, 5000,0.6, {c,w,p}]; > > > Plot[{xd[t],xr[t]},{t,0,100}, > > > PlotStyle\[Rule]{RGBColor[1,0,0.3],RGBColor[0,0.5,1]}]; > > > > > > > > > > > > W.GARIRA > > > E-mail: w.garira at ucl.ac.uk > > > phone : +44-(0)20-7679-2521 > > > ___________________________________________________ > > > > > > > > > > > > > > > > > > Winston, > > You are getting listed values like > > > > xd[4] > > > > {1.24463} > > > > Plot lets us get away with this (it flattens the input), but ParametricPlot > > assumes that {{x1[t]},{x2[t]}} is an error for something like > > {{x1[t]`y1[t]},{x2[t], y2[t]}} . > > > > One way out is to replace > > > > xd[t_] := Evaluate[x1[t] /. pend]; > > etc > > > > with > > > > xd[t_] = x1[t] /. pend[[1]]; > > > > etc > > > > (the Evaluate is unnecessary if we use = instead of :=) > > > > -- > > Allan > > --------------------- > > Allan Hayes > > Mathematica Training and Consulting > > Leicester UK > > www.haystack.demon.co.uk > > hay at haystack.demon.co.uk > > Voice: +44 (0)116 271 4198 > > Fax: +44 (0)870 164 0565 > > > > >