Group Abstract Group Abstract

Message Boards Message Boards

Manipulate and dynamic complex input fields

Posted 10 years ago
POSTED BY: Erdem Uguz
10 Replies
POSTED BY: Patrik Ekenberg
Posted 10 years ago

here I adapt the inputfield for xL and xR but I would like to have tags for there on the left such as Lower Limit = "Inputfield" Upper Limit = .. Function = ... Result = FieldHint -> "Enter a string" does not work I think because I set the inputfields to a number. How can put these name tags?

Manipulate[
 Panel[DynamicModule[{f = Sin[x], xR = 1, xL = 0}, 
   Column[{InputField[Dynamic[xL]], InputField[Dynamic[xR]], 
     InputField[Dynamic[f]], 
     Dynamic[NumberForm[
       NIntegrate[f, {x, xL, xR}, WorkingPrecision -> nw], 
       np]]}]]], {{np, 10, "NumberFormat"}, 10, 30, 
  1}, {{nw, 16, "WorkingPrecision"}, 10, 30, 1}]
POSTED BY: Erdem Uguz
Posted 10 years ago
POSTED BY: Erdem Uguz

That it really cool!

It got me thinking about whether you can enter arbitrary function which contain arbitrary parameters, like you could for example specify Sin[k x +m] or Sin[k^m * x].

The first problem that arose was that the expression entered was evaluated directly. Using input field, you can specify that the input should be an held expression.

Secondly when I wrote the parameter "o" into my expression ("o" being a parameter that was controlled by manipulate) the expression though I meant the "o" symbol from the global context, rather than the unique "o" created within the manipulate context. I fixed this by renaming the manipulated variable "oval" and since the expression was held, I could replace every instance of Global`o with the unique oval, before releasing the hold.

Manipulate[
 Dynamic[
  Plot[ReleaseHold[ReplaceAll[f, {o -> oval, p -> pval}]], {x, -5, 5}]
  ],
 {{oval, 1, "o"}, 1, 10},
 {{pval, 2, "p"}, 2, 10},
 {{f, Hold[Sin[o x + p]]}, InputField[Dynamic[f], Hold[Expression]] &}]

interactive plot

Cheers!

POSTED BY: Patrik Ekenberg
Posted 10 years ago

I made something like this

Manipulate[
 Panel[DynamicModule[{f = Sin[x]}, 
   Column[{InputField[Dynamic[f]], 
     Dynamic[NumberForm[NIntegrate[f, {x, xL, xR}], np]]}]]], {xL, 0, 
  1}, {xR, 0, 1}, {np, 10, 30, 1}]

It works for CDF ...

POSTED BY: Erdem Uguz
POSTED BY: Sam Carrettie
Posted 10 years ago

I believe there is at least for Enterprise CDF which I use but to be honest documentation is not as good as MATLAB.

POSTED BY: Erdem Uguz

I am afraid CDF has severe limitations to the kind of inputs it allows. I hope somebody else will give some details.

POSTED BY: Gianluca Gorni
Posted 10 years ago
POSTED BY: Erdem Uguz

If you can live with a fixed menu of functions you can do something like this:

Manipulate[
 Plot[f[o x + p], {x, -a, a}], {f, {Sin, Cos, Tan, Exp}}, {o, 1, 
  10}, {p, 2, 10}, {{a, Pi}, 1, 5 Pi}]

This should transfer to cdf.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard