Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5716
| From | Lengyel Tamas <lt648@hszk.bme.hu> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Manipulate in a series of commands |
| Date | 2011-10-19 09:37 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j7m5oo$jmp$1@smc.vnet.net> (permalink) |
Dear Community,
I am faced with a probably very easy problem. At the bottom you can see my
code which executes in a single cell once the parameter K is set to an
integer number greater than 0.
I can't seem to make it Dynamic or use Manipulate, e.g. have a slider or
text box where I can change the number K, then have the series of commands
executed.
Any ideas?
Tamás
Code:
K = 64;
Element[n, Integers];
Degen = Piecewise[{{0,
n < -K}, {(K - Ceiling[(K - n)/2]), -K <= n <=
0}, {(K - 1 - Floor[n/2] - Ceiling[(K - n)/2]),
0 < n <= K}, {(K - Floor[n/2]), K < n <= 2 K}, {0, n > 2 K}}];
g1 = DiscretePlot[Degen, {n, -K, 2 K}, AxesOrigin -> {-K, 0},
PlotRange -> {{-K, 2 K}, {0, K^2/2.5}},
PlotStyle -> {Thickness[0.01]},
FillingStyle -> RGBColor[0.4, 1, 0.4, .9]];
NonDegen =
Piecewise[{{0,
n < -K}, {(Ceiling[(K^2 + n^2 - 2*K - 2 n + 2*K*n)/4]), -K <=
n <= 0}, {(Ceiling[(K^2 - 6 K - 2 n^2 + 2 n + 4)/4 +
Floor[(K*n)/2]]),
0 < n <= K}, {(Floor[(4 K^2 + n*n - 4 K*n)/4]),
K < n <= 2 K}, {0, n > 2 K}}];
g2 = DiscretePlot[Degen + NonDegen, {n, -K, 2 K},
AxesOrigin -> {-K, 0}, PlotRange -> {{-K, 2 K}, {0, K^2/2.5}},
PlotStyle -> {Thickness[0.01]},
FillingStyle -> RGBColor[0.01, 0.01, 2, 1]];
g3 = DiscretePlot[((K/2 - 1) + (K^2 - 6*K + 2*K*n - 2 n^2 + 2 n + 4)/
4), {n, 1, K}, AxesOrigin -> {-K, 0},
PlotRange -> {{-K, 2 K}, {0, K^2/2.5}},
ColorFunction -> (RGBColor[#2, 0.2, 1 - #2] &),
FillingStyle -> {Directive[{Thickness[0.01], Opacity[0.9] }]},
Filling -> Axis];
Show[g2, g3, g1, AxesLabel -> {"n", "Number of FWM products"},
LabelStyle -> Directive[Black, Bold, 14]]
max = FindMaxValue[((K/2 - 1) + (K^2 - 6*K + 2*K*n - 2 n^2 + 2 n + 4)/
4), n];
Floor[max]
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Manipulate in a series of commands Lengyel Tamas <lt648@hszk.bme.hu> - 2011-10-19 09:37 +0000
csiph-web