Re: manipulate time
- To: mathgroup at smc.vnet.net
- Subject: [mg114772] Re: manipulate time
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Thu, 16 Dec 2010 05:50:59 -0500 (EST)
- References: <ieadlm$ra7$1@smc.vnet.net>
Am 15.12.2010 13:52, schrieb manel zerelli: > i want to solve two differential equations in which a parameter "r" > vary in an intervall. for that i want to see the effect of this > variation at each time.i want to manipulate time and for each instant > i scan all the interval of variation of parameter "r". > i tried this: > > Manipulate[ > For[r = 1, r < 4, r++, > sol = DSolve[{\[Theta]'[t] == k i[t], > i'[t] == -k \[Theta][t] - r i[t] + 10, > i[0] == 0, \[Theta][0] == 0}, {i, \[Theta]}, t]; > ParametricPlot[Evaluate[{i[t], \[Theta][t]} /. sol], {t, 0, n}, > PlotRange -> {{-10, 10}, {-1, 15}}]], {n, 0, 7}] > > and i tried tu use two for loop > > For [t = 0.1, t < 7, t++, > For[r = 1, r < 3, r++, > sol = DSolve[{\[Theta]'[t] == k i[t], > i'[t] == -k \[Theta][t] - r i[t] + 10, > i[0] == 0, \[Theta][0] == 0}, {i, \[Theta]}, t]; > ParametricPlot[Evaluate[{i[t], \[Theta][t]} /. sol], {t, 0.1, 7}, > PlotRange -> {{-10, 10}, {-1, 15}}]]] > > i am a new user of mathematica so i am sorry for the syntax error! > can you help me o solve this problem > there are various problems with your code, here is something that should work, although I'm not sure whether it is what you intended: sol = First[{i[t], \[Theta][t]} /. DSolve[{\[Theta]'[t] == k i[t], i'[t] == -k \[Theta][t] - r i[t] + 10, i[0] == 0, \[Theta][0] == 0}, {i, \[Theta]}, t]] Manipulate[ Row[Table[ ParametricPlot[Evaluate[sol /. {k -> kk}], {t, 0, n}, PlotRange -> {{-10, 10}, {-1, 15}}, Frame -> True, ImageSize -> 150, Axes -> False], {r, 1, 3} ]], {n, 0.01, 7}, {kk, 0.1, 10} ] some of the things I changed: 1) k had no value, so I inserted one with a secon manipulate variable 2) the DSolve was called way too often... 3) For does not return anything, and that is not the most important reason to avoid it in Mathematica. 4) parametertic plot didn't like to plot from t=0 to 0, so I changed the minimal n value to 0.01. hth, albert