I am compiling a calculator where many slider parameters are used to define a value, where the defined value may then be reused to define another value. I am unable able to, or at least been unsuccessful in assigning these values as variables.
I want my coding to be able to refer to a variable (where the variable is an equation) in the sense, however the equation is defined by slider parameters and doesn't initially contain values.
An example of this is a three-step formulation, where the first equation requires parameters defined through sliders, a second equation requires the value from the first equation and another slider parameter, then a third equation requires the value from the second equation and another slider; variables A, C and F are defined from individual sliders like this:
Row[{"Magnification: ", F/C}],
Row[{"Exit Pupil: ", A/(F/C)}],
Row[{"Longest Useful FOV: ", F/(A/(F/C))}],
{{A, 130, "Aperature: "}, 60, 508, 1, Appearance -> "Labeled"},
{{F, 650, "Focal Length: "}, 480, 4064, 1, Appearance -> "Labeled"},
{{C, 32, "Occular Focal Length: "}, 1, 110, 1, Appearance -> "Labeled"},
An easier way to express this would be and how I would like it to display is like this:
Row[{"Magnification: ", F/C = M}],
Row[{"Exit Pupil: ", A/M = E}],
Row[{"Longest Useful FOV: ", F/E}],
I am unable to find a way where this is achieved, the calculator hosts several instances like this however some require the value from another equation without a parameter set from a slider. Some equations are reused multiple times, due to the equations being used there are inconsistencies with formulation until some sliders have changed their values.
I have a working example with complete code if required to see the depth of the formulation, however none of the equations require more than a three-step formulation.
Edit - Full Code
$S1 = Bold;
$S2 = Orange;
Manipulate[
N@Grid[{
{Style["Focal Ratio: ", $S1], Style[FL/AD, $S2]},
{Style["Dawes Limit: ", $S1], Style[115.824/AD, $S2]},
{Style["Rayleigh Limit: ", $S1], Style[139.7/AD, $S2]},
{Style["Gathering Power: ", $S1], Style[(AD/OP)^2, $S2]},
{Style["Magnification: ", $S1], Style[N[FL/OL, 4], $S2]},
{Style["Min Magnification: ", $S1], Style[N[AD/OP, 4], $S2]},
{Style["Exit Pupil: ", $S1], Style[N[AD/(FL/OL), 3], $S2]},
{Style["True FOV (No F/Stop): ", $S1], Style[N[OF/(FL/OL), 3], $S2]},
{Style["True FOV (F/Stop): ", $S1], Style[N[(.0957*OL*OF*N[Pi]/180)/FL 57.3, 3], $S2]},
{Style["Max FOV: ", $S1], Style[N[31.7 180/N[Pi]/FL, 3], $S2]},
{Style["Longest Useful FOV: ", $S1], Style[N[FL/(AD/(FL/OL)), 5], $S2]},
{Style["Magnitude Limit: ", $S1], Style[NumberForm[7.5 + 5 Log10[AD/10], 4], $S2]},
{Style["Ocular Field Stop: ", $S1], Style[N[.0957*OL*OF*N[Pi]/180, 4], $S2]}
}],
{{AD, 130, "Aperature: "}, 60, 508, 1, Appearance -> "Labeled"},
{{FL, 650, "Focal Length: "}, 480, 4064, 1, Appearance -> "Labeled"},
{{OL, 32, "Occular Focal Length: "}, 1, 110, 1, Appearance -> "Labeled"},
{{OF, 52, "Occular FOV: "}, 40, 72, 1, Appearance -> "Labeled"},
{{OP, 7, "Observer's Pupil: "}, 4, 9, 1, Appearance -> "Labeled"}
]
I reworked the layout to a Grid
, I will have to adjust the decimals still. There are no more compiling errors, however the instance I want to adjust is being able to refer to a variable say with the Exit Pupil rather than reusing the Mag formula, there are many instances where I have reused the same formulas multiple times, if I can set some of the equations to a variable it will significantly reduce the size and unnecessary complexities. Is there a way I can do this?
Manipulate[ ]
in the docs? $\endgroup$ – Dr. belisarius Dec 12 '13 at 6:40Manipulate
and see if it's any help. $\endgroup$ – Ashley James Dec 12 '13 at 6:46C
has built-in meaning too. $\endgroup$ – Kuba♦ Dec 12 '13 at 7:24E
does. That explains why I get a few of the errors compiling. $\endgroup$ – Ashley James Dec 12 '13 at 7:30