0
$\begingroup$

I have two functions which depend on the same parameters and I want to make a manipulate box with both of them, but I want to use one slider to control both function (so I can compare how change in a parameter affects both of them).

The easiest way would be to use Plot command with both of them inside, but they have different y axis so I cannot use it.

For now I use Panel and I have two graphs next to each other, but they have separate sliders with the same parameters.

What is the way out of this?

EXAMPLE

Panel[Manipulate[
   Plot[-9.81*t, {t, 0, Sqrt[2*h/9.81]}, PlotStyle -> Red ], {h , 1, 
    100}] Manipulate[
   Plot[h - 9.81*t^2/2, {t, 0, Sqrt[2*h/9.81]}], {h, 1, 100}] , 
 FrameMargins -> 0]
$\endgroup$
  • 1
    $\begingroup$ Could you add code examples. Its much easier to understand what you are talking about, and its much more likely that somebody would help you if you place code examples (properly formatted) that can be copied easily into Mathematica session. $\endgroup$ – ercegovac Feb 3 '17 at 16:08
  • $\begingroup$ @ercegovac thanks for the tip! Added a simple example, as you suggested $\endgroup$ – 10001000101111 Feb 3 '17 at 16:17
  • 2
    $\begingroup$ Manipulate[Row@{ Plot[a, {x, 0, 1}, PlotRange -> {0, 10}, ImageSize -> Large], Plot[2 a, {x, 0, 10}, PlotRange -> {0, 10}, ImageSize -> Large] }, {a, 0, 5} ] $\endgroup$ – grbl Feb 3 '17 at 16:18
  • $\begingroup$ Thanks @grbl. What is the "@" sign for? Is it part of Row function? $\endgroup$ – 10001000101111 Feb 3 '17 at 16:24
  • $\begingroup$ @lough_or_cry , you should really familiarize yourself with Mathematica and its paradigm (functional programming). In this particular case @ stands for Prefix operator (search Mathematica help, its powerful ). I'd recommend the following link it gives some useful tips and tricks to jump-start with Mathematica. $\endgroup$ – ercegovac Feb 3 '17 at 16:27
1
$\begingroup$

Full example of my comment:

Manipulate[
   Column@{Plot[-9.81*t, {t, 0, Sqrt[2*h/9.81]}, PlotStyle -> Red, 
    Frame -> True, 
    ImagePadding -> {{30, 10}, {30, 10}}],
   Plot[h - 9.81*t^2/2, {t, 0, Sqrt[2*h/9.81]}, Frame -> True, 
     ImagePadding -> {{30, 10}, {30, 10}}]},
   {h,1, 100}]
$\endgroup$
  • $\begingroup$ I have problems with adjusting the spacing between the graphs: usually I would use Column[{},Spacings -> s], but it doesn't seem to work $\endgroup$ – 10001000101111 Feb 4 '17 at 10:38
0
$\begingroup$

This seems to work too for your particular example.

Manipulate[Show[Plot[-9.81*t, {t, 0, Sqrt[2*h/9.81]}, PlotStyle -> Red, 
Frame -> True, ImagePadding -> {{30, 10}, {30, 10}}, PlotRange -> All], 
Plot[h - 9.81*t^2/2, {t, 0, Sqrt[2*h/9.81]}, Frame -> True, 
ImagePadding -> {{30, 10}, {30, 10}}, PlotRange -> All]], {h, 1,100}]

enter image description here

$\endgroup$

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.