0

Please have a look at below. I need to solve two-coupled equations and plot the results h[2] and theta[2]. I am not sure about the function definition for p01 and p02 which use x as a variable not h[2] and theta[2]. Then I put these p01, p02 inside first, second, etc which use h[2] and theta[2] as argument. I guess that part cause the problem for manipulate..

p01[x_] := 2*h[2]/k*Log[(x - b)/(-b)] + theta[2]/k*x + 1/2;

p02[x_] := 2*h[2]/k*Log[(x - b)/(1 - b)] + theta[2]/k*(x - 1); 

first[h[2] _, theta[2] _] := Integrate[p01[x], {x, 0, b}, Assumptions -> 0 < b < 1]

second[h[2] _, theta[2] _] := Integrate[p02[x], {x, b, 1}, Assumptions -> 0 < b < 1]

third[h[2] _, theta[2] _] := Integrate[(x - b)*p01[x], {x, 0, b}, Assumptions -> 0 < b < 1]

fourth[h[2] _, theta[2] _] := Integrate[(x - b)*p02[x], {x, b, 1}, Assumptions -> 0 < b < 1]

Solve[2*M*h[2] == first[h[2] _, theta[2] _] + second[h[2] _, theta[2] _] - 
M*g && 2*M*gamma*theta[2] == third[h[2] _, theta[2] _] + fourth[h[2] _, 
theta[2] _], {h[2], theta[2]}]

h[0] = k*b*(1 - b);
theta[0] = k*(1 - 2*b);
height[t_] := h[0] + t^2*h[2];
angle[t_] := theta[0] + t^2*theta[2];

Manipulate[
Plot[ h[0] + t^2*h[2], {t, 0, 0.1}, Filling -> filling, 
PlotRange -> {0.232, 0.245}], {M, {None, 1, 0.5, 0.2, 0.1, 0}}, {M, 
0, 1}, {g, {None, 10, 5, 2, 1, 0.5, 0.1, 0}}, {g, 0, 10},
{b, {None, 1, 0.6, 0.5, 0.3, 0}}, {b, 0, 1},
{gamma, {None, 1, 0.5, 0.2, 0}}, {gamma, 0, 1},
{k, {None, 1, 0.5, 0.2, 0}}, {k, 0, 1},
{filling, {None, 2, 1.5, 1, 0.5, 
0, -0.5, -1, -1.5, -2}}, {filling, -2, 2}, SaveDefinitions -> True]
Meva
  • 223
  • 2
  • 8
  • 1
    This is essentially the same problem as you ran into in this question. Did you read the linked duplicate? Manipulate scopes its variables, so you have to tell Manipulate that those variables are there, either with the replacement rule trick explained by @feyre, or by redefining your functions to include the variables, i.e. h[2, M_, g_] := ... rather than h[2, M, g]. – march Oct 13 '16 at 16:37
  • Thanks @march, I see what you mean. However, I have lots of parameters that the plot needs to be manipulated with, namely M, g, b, gamma, k. As I used height[t_, kappa_, b_, M_, g_, gamma_] insideManipulate, I have below code:Manipulate[ Plot[ height[t_, [Kappa], b, M_, g_, [CapitalGamma]_], {t, 0, 0.1}, Filling -> filling, PlotRange -> .....` However, I do not have any luck.. – Meva Oct 13 '16 at 23:58

0 Answers0