1
$\begingroup$

I have got a long expression called h, which I don't think is relevant to define here for the issue I have. Just know that it was defined through symbols, like

 h=C1*Sin[...]*Integrate[...] etc. 

So my definition has no [x_] or := It seems to work well until here (I get the long expression for h in terms of the symbols) Then, what I would like to do is defining a function with all the undefined parameters that appear in h, that is, in my case:

h1[x_,alpha_,beta_,L_,Lc_]=h;

After that, I would like to make a Manipulate plot such as, for example:

Manipulate[
Plot[Re[h1[x, alpha, beta, L, Lc]], {x, 0.1, 1}, 
PlotLegends -> {"h(x)"}], {beta, 0, 1},{alpha, 0, 1},{L, 0, 1},{Lc, 0, 1}]

However, it doesnt work. Where are my mistakes?

$\endgroup$
0

1 Answer 1

1
$\begingroup$

Model your code on the following:

Block[{x, a, b}, h[x_, a_, b_] = a Sin[b x]];
Manipulate[
  Plot[h[x, a, b], {x, 0, 10},
    PlotRange -> {-1, 1}],
  {a, -1, 1},
  {b, π/4, 2 π, π/4}]

demo

$\endgroup$
3
  • $\begingroup$ What is the block function doing? I would like to remind you also that on the rhs of h[x_,a_,b_] I dont want to right the expression but to state simply h Is that allowed? $\endgroup$ Commented Mar 27, 2017 at 7:54
  • $\begingroup$ I am getting $Aborted or an empty Plot. I read somewhere else that this is due to long expressions inside Manipulate. Some sort of bug/crash? $\endgroup$ Commented Mar 27, 2017 at 9:07
  • $\begingroup$ @AndreaG. Blockprotects the rhs of the definition from being contaminated by global definitions of x, a and b. Sorry but I can't answer the additional questions. The one about h being allowed make no sense. The one about your crashes/aborts can't be tested without knowing the expression you are using. $\endgroup$ Commented Mar 27, 2017 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.