As in the title. I want them to be on the same graph. Additionaly i want to the graph to always be focused on the rectangle.
f[x_, x0_, a_, n0_, C_] := -1/a + C/(a*n0)*Cosh[a*n0/C*(x - x0)]
Show[
Graphics[{Thick, Opacity[0.5], LightBlue, Rectangle[{0, -1}, {3, 1}]}]
Manipulate[
Plot[f[x, x0, a, n0, c],
{x, 0, 3}],
{x0, 0, 10},
{a, -1, 1},
{n0, 1, 2},
{c, 0.1, 10}]]
Second question, I don't know if i should make another thread about it. How to add two points where the rectangle and function collide?
Answer
You can also use the rectangle as a Prolog
or Epilog
in Plot
so that you don't have to use Show
.
The intersection of the rectangle with the plotted line can be highlighted using Mesh*
options:
Manipulate[Plot[f[x, x0, a, n0, c], {x, 0, 3},
PlotRange -> {{-1, 4}, {-2, 4}}Frame -> True, Axes -> False,
MeshStyle -> Directive[Green, PointSize[Large]],
MeshFunctions -> {#2 &}, Mesh -> {{1, -1}},
MeshShading -> {Blue, Red}, BaseStyle -> Thick,
Prolog -> {EdgeForm[{LightBlue, Thick}], Opacity[0.5], LightBlue,
Rectangle[{0, -1}, {3, 1}]}],
{{x0, 1.5}, 0, 10}, {{a, -.3}, -1, 1}, {{n0, 1.1}, 1, 2}, {{c, 0.1}, 0.1, 10}]
Comments
Post a Comment