0
$\begingroup$

I have this function

enter image description here

With 3 constants, R, c, and V. The question I have in hand is to show how the solution curve changes as the parameters change so I need to plot this function with several different value of each constant, other than plotting each function many times is there a way to plot this function just once with a slider to be able vary the constants? I tried looking Plot[Table and Manipulate function but that didn't help me a lot. I also tried looking into the plot function. How can I plot this function?

$\endgroup$
2
$\begingroup$

One way might be to use Manipulate

enter image description here

Manipulate[
 sol = q[t] /. 
   First@DSolve[{r q'[t] + q[t]/c == v, q[0] == ic}, q[t], t];
 Grid[{{sol},
   {Plot[sol, {t, 0, maxT}, PlotRange -> {{0, maxT}, {0, maxQ}}, 
     ImagePadding -> 40, ImageSize -> 300, Frame -> True, 
     FrameLabel -> {{"q(t)", None}, {"t", "Solution to the problem"}},
      GridLines -> Automatic, GridLinesStyle -> LightGray, 
     PlotStyle -> Red]
    }}],

 {{c, 1.6, "c"}, 0, 2, .1, Appearance -> "Labeled", ImageSize -> Tiny},
 {{r, .1, "r"}, .1, 2, .1, Appearance -> "Labeled", ImageSize -> Tiny},
 {{v, 1.5, "c"}, .1, 2, .1, Appearance -> "Labeled", ImageSize -> Tiny},
 {{ic, 1, "q[0]"}, 0, 2, .1, Appearance -> "Labeled", ImageSize -> Tiny},
 {{maxT, 1, "time scale"}, 1, 100, .1, Appearance -> "Labeled", ImageSize -> Tiny},
 {{maxQ, 3, "y scale"}, .1, 10, .1, Appearance -> "Labeled", ImageSize -> Tiny}
 ]
$\endgroup$
  • $\begingroup$ For some reason everytime I use the Manipulate function it gives me the definition of the word Manipulate instead, what am I doing wrong? its on Mathematica web $\endgroup$ – method Apr 19 '17 at 5:49
  • 1
    $\begingroup$ @method it is here reference.wolfram.com/language/ref/Manipulate.html I find using google search "Mathematica manipulate" $\endgroup$ – Nasser Apr 19 '17 at 5:51
  • $\begingroup$ here's what I am getting i.imgur.com/QFvjBsK.png, I have tried to use a function from the reference link and it seemed to work but I tried to hand write the one you gave me too still getting the definition $\endgroup$ – method Apr 19 '17 at 6:06
  • 1
    $\begingroup$ @method I do not use Mathematica online, so I am not sure why it does not work there. so I can't really help on that. I use Wolfram Mathematica desktop (on the PC) not on the cloud one. May be someone else knows why it does not work on Wolfram online. $\endgroup$ – Nasser Apr 19 '17 at 6:15
  • 2
    $\begingroup$ @method In the image you linked that first orange equal sign is suspicious. It means you are calling WolframAlpha and I think you don't need this. I have tried @Nasser Manipulate code in online programing lab and it works. $\endgroup$ – Pinti Apr 19 '17 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.