1
$\begingroup$

I have a function F(x1,x2,...,xi;y1,y2,...,yj) such that the xi are the variables and the yj are other parameters (as constants) of the same function.

I need that:

  1. The user defines the number of variables and the number of parameters.
  2. The user defines the name of the variables and the parameters.
  3. Finally with this information loaded the user will define their values and a function that depends on the previous steps, then the operations defined for the function F(x;y) will be performed.

This is what I have done:

For step 1:

Panel[Manipulate[tick;
Grid[{{Style["Input data", "Title"], SpanFromLeft}, {Control@{{numberxvar, Null, 
    Style["Number of variables", Bold, 12]}, 
   InputField[#, Number, Background -> Lighter[Gray, 0.7], 
     ImageSize -> 80] &}}, {Control@{{numberxpar, Null, 
    Style["Number of constants", Bold, 12]}, 
   InputField[#, Number, Background -> Lighter[Gray, 0.7], 
     ImageSize -> 80] &}}, {Button[Style["Do it", Bold, 12], 
  tick = Not[tick], Background -> Lighter[Blue, 0.7], 
  ImageSize -> {80, 40}]}}], {{tick, False}, None},TrackedSymbols :> {tick}, ControlPlacement -> Left,SaveDefinitions -> True]]

For example, if the user enters number of variables equal to 2 and number of parameters equal to 3.

Step 1

For step 2:

Panel[
Manipulate[tick;
Grid[{
{Style["Parameter and variable names", "Title"], SpanFromLeft, 
 SpanFromLeft},
{
 Control@{{variablename, Null, 
    Style["Variable name 1", Bold, 12]}, 
   InputField[#, String, Background -> Lighter[Gray, 0.7], 
     ImageSize -> 80] &}
 },
{
 Control@{{variablename2, Null, 
    Style["Variable name 2", Bold, 12]}, 
   InputField[#, String, Background -> Lighter[Gray, 0.7], 
     ImageSize -> 80] &}
 },
{
 Control@{{parametername, Null, 
    Style["Parameter name 1", Bold, 12]}, 
   InputField[#, String, Background -> Lighter[Gray, 0.7], 
     ImageSize -> 80] &}
 },
{
 Control@{{parametername2, Null, 
    Style["Parameter name 2", Bold, 12]}, 
   InputField[#, String, Background -> Lighter[Gray, 0.7], 
     ImageSize -> 80] &}
 },
{
 Control@{{parametername3, Null, 
    Style["Parameter name 3", Bold, 12]}, 
   InputField[#, String, Background -> Lighter[Gray, 0.7], 
     ImageSize -> 80] &}
 },
{Button[Style["Do it", Bold, 12], tick = Not[tick], 
  Background -> Lighter[Blue, 0.7], ImageSize -> {80, 40}]}
}],
{{tick, False}, None}, TrackedSymbols :> {tick}, 
ControlPlacement -> Left, SaveDefinitions -> True]]

For example:

Step 2

For step 3:

Manipulate[tick; 
 If[AllTrue[{xvar1Min, xvar1Max, xvar2Min, xvar2Min, xpar1, xpar2, 
    xpar3}, NumericQ], 
  Plot3D[dxvar /. {Xvar1 -> xvar1, Xvar2 -> xvar2, Xpar1 -> xpar1, 
     Xpar2 -> xpar2, Xpar3 -> xpar3}, {xvar1, xvar1Min, 
    xvar1Max}, {xvar2, xvar2Min, xvar2Max}], Graphics[{}]],
 Grid[{
   {Style["Work area", "Title"], SpanFromLeft, SpanFromLeft},
   {Control@{{xpar1, Null}, InputField[#, Number] &}, 
    Control@{{xpar2, Null}, 
      InputField[#, Number] &}}, {Control@{{xpar3, Null}, 
      InputField[#, Number] &}, 
    SpanFromLeft}, {Control@{{xvar1Min, Null}, 
      InputField[#, Number] &}, 
    Control@{{xvar1Max, Null}, 
      InputField[#, Number] &}}, {Control@{{xvar2Min, Null}, 
      InputField[#, Number] &}, 
    Control@{{xvar2Max, Null}, InputField[#, Number] &}},
   {Button[Style["Do it", Bold, 12], tick = Not[tick], 
     Background -> Lighter[Blue, 0.7], 
     ImageSize -> {80, 40}]}}], {{dxvar, 
   3 (Xpar1*Xvar1) + 2 (Xpar2*Xvar2) + Xpar3, "Equation", 
   None}}, {{tick, False}, None}, TrackedSymbols :> {tick}, 
 ControlPlacement -> Left, SaveDefinitions -> True, 
 ControlPlacement -> Left]

For example, if the function F(x;y)=F(x1,x2;y1,y2,y3) where the operation to be performed is a 3D-graph.

Step 3

My problem is how to join these pieces and that is done automatically.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.