Re: Plot to Plot3D problem
- To: mathgroup at smc.vnet.net
- Subject: [mg83438] Re: Plot to Plot3D problem
- From: Jerry <JLK2941 at yahoo.com>
- Date: Tue, 20 Nov 2007 03:56:44 -0500 (EST)
- References: <fhp603$3bm$1@smc.vnet.net> <fhrr1t$535$1@smc.vnet.net>
Peter, thanks a lot. Even though I still get lots of error messages, at least your code returns a plot. After the Plot3D I get: NDSolve::dsvar: "-1.99986 cannot be used as a variable." and a long string of these: ReplaceAll::reps: {(vo')[-1.99986]==14.4013-4.99952 vo[-1.99986],vo[-5]==0} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. But I won't worry why, the error messages never make any sense to me; at least if coughed up a plot. One more question please: I see you use the expression (vo /. sol[10^lrf])[t] in Plot3D I've seen something like this before but I have no clue what that extra [t] means. If I remove the [t] I get the same error messages and a plot frame but with no plot in it. So apparently it's something special for Plot3D? It's not needed at all in Plot. I've never found any useful explanation of [] in the Help. You asked why I didn't just use DSolve. The main reason is that as soon as I put any type of interesting DE in there, DSolve will fail. I've learned to just use NDSolve to start with and it will work in many more instances. But DSolve would probably work fine for this simple DE I'm using here. Thanks again for your time, Jerry. Peter Pein wrote: > Hi Jerry, > > I guess there is a reason why you do not DSolve your equation and work with that result... > > I'm using Version 5.2. > > The Rf in the pattern sol[Rf_] is another one than the Rf used in the rest of your example. > To avoid trouble, use: > sol[rf_] := First@NDSolve[eqs /. Rf -> rf, vo, {t, -10, 5}] > > If you use Evaluate in the Plot3D function, evaluation will take place before a value for sol[..] is known. > > I used successfully > Plot3D[(vo /. sol[10^lrf])[t], {t, -2, 5/2}, {lrf, 4, 7}, PlotRange -> All, > AxesLabel -> {"t", "log10(Rf)", "vo"}, PlotPoints -> {33, 49}, > Mesh -> False] > > (I changed the scale of Rf to logarithmic, because the linear scale seemed boring to me) > > HTH, > Peter > > > Jerry schrieb: >> Greetings all. Could someone please give me a tip on what >> I'm doing wrong when trying to convert a working Plot >> routine to a Plot3D routine? >> >> I'm using V6.01 on XP. >> >> The first code set below works fine, using a fixed value for >> the parameter Rf. >> >> In the second code set, I don't set parameter Rf and I try >> to use it as one variable in Plot3D. I've tried every >> combination of set or set delayed for eqs and sol and tried >> inserting Evaluate all over the place and haven't hit >> goodness yet. Clearly I'm not ready for prime time on my own. >> >> Would appreciate any suggestions. >> >> >> >> (* this works *) >> a = 1.0; w = 1.57; >> Rf = 1*10^6; >> R = 1000; c = 2*10^-6; >> >> v2[t_] := Exp[-a t^2] Sin[w t]; >> v3[t_] := v2'[t]; >> >> eqs = {vo'[t] == -(v3[t]/R/c + vo[t]/Rf/c), vo[-5] == 0}; >> >> sol = NDSolve[{eqs}, vo, {t, -10, 5}] >> >> Plot[ Evaluate[ vo[t] /. sol], {t, -5, 5} ] >> >> ********************** >> >> (* this doesn't work *) >> a = 1.0; w = 1.57; >> (* parameter Rf specified in Plot3D below *) >> R = 1000; c = 2*10^-6; >> >> v2[t_] := Exp[-a t^2] Sin[w t]; >> v3[t_] := v2'[t]; >> >> eqs = {vo'[t] == -(v3[t]/R/c + vo[t]/Rf/c), vo[-5] == 0}; >> >> sol[Rf_] := NDSolve[{eqs}, vo, {t, -10, 5}] >> >> Plot3D[ Evaluate[ vo[t] /. sol[Rf] ], {t, -5, 5}, >> {Rf, 1*^6,5*^6} ] >> >