Discussion:
Problem in using preassigned variable in manipulate
(too old to reply)
Pooja Tewari
2012-05-04 02:26:11 UTC
Permalink
Hi,

I am new to Mathematica and I have been stuck with this seemingly small issue for some time now -

x:=.5;

g = Manipulate[
Plot[Sin[i t], {t, 0, 10},
ImageSize -> Scaled[x]], {i, 1, 5}]

I want to assign the variable x to .5 and then use it in Manipulate function, which plot a graph of sin[i t] and imagesize should be scaled to x( which is already assigned). But when I am deploying this in cdf, I am having this error

"The specified setting for the option GraphicsBoxOptions, ImageSize cannot be used."
John Fultz
2012-05-04 10:27:10 UTC
Permalink
There are several ways to do this. In this case, I would use With:

With[{x=.5}, g=Manipulate[=85]]

This literally substitutes .5 into the resulting expression before it's
evaluated. Another common possibility is to assign it to a
DynamicModule variable, which will remain present and properly
initialize in the resulting CDF:

DynamicModule[{x=.5}, g=Manipulate[=85]]

Sincerely,

John Fultz
***@wolfram.com
User Interface Group
Wolfram Research, Inc.
Post by Pooja Tewari
Hi,
I am new to Mathematica and I have been stuck with this seemingly
small issue for some time now -
Post by Pooja Tewari
x:=.5;
g = Manipulate[
Plot[Sin[i t], {t, 0, 10},
ImageSize -> Scaled[x]], {i, 1, 5}]
I want to assign the variable x to .5 and then use it in Manipulate
function, which plot a graph of sin[i t] and imagesize should be scaled
to x( which is already assigned). But when I am deploying this in cdf, I
am having this error
Post by Pooja Tewari
"The specified setting for the option GraphicsBoxOptions, ImageSize
cannot be used."
Christoph Lhotka
2012-05-04 10:29:12 UTC
Permalink
hello,

your cdf file does not store the definition for x in your case.

Use therefore

g = Manipulate[
Plot[Sin[i t], {t, 0, 10}, ImageSize -> Scaled[x]], {i, 1, 5},
Initialization :> {x := .5}]

or use

x:=.5
g=Manipulate[Sin[i t], {t, 0, 10}, ImageSize -> Scaled[x]], {i, 1, 5},
SaveDefintions->True].

to safe any definitions associated to expr.

Best,

Christoph


#
Post by Pooja Tewari
Hi,
I am new to Mathematica and I have been stuck with this seemingly small issue for some time now -
x:=.5;
g = Manipulate[
Plot[Sin[i t], {t, 0, 10},
ImageSize -> Scaled[x]], {i, 1, 5}]
I want to assign the variable x to .5 and then use it in Manipulate function, which plot a graph of sin[i t] and imagesize should be scaled to x( which is already assigned). But when I am deploying this in cdf, I am having this error
"The specified setting for the option GraphicsBoxOptions, ImageSize cannot be used."
Murray Eisenberg
2012-05-05 08:14:12 UTC
Permalink
I missed the "deploying this in cdf" sentence, so my original response
is irrelevant.
Your code works perfectly as is for me (Mathematica 8.0.4).
f[x_] := Manipulate[
Plot[Sin[i t], {t, 0, 10},
ImageSize -> Scaled[x]],
{i, 1, 5}]
Post by Pooja Tewari
Hi,
I am new to Mathematica and I have been stuck with this seemingly
small issue for some time now -
x:=.5;
g = Manipulate[
Plot[Sin[i t], {t, 0, 10},
ImageSize -> Scaled[x]], {i, 1, 5}]
I want to assign the variable x to .5 and then use it in Manipulate
function, which plot a graph of sin[i t] and imagesize should be
scaled to x( which is already assigned). But when I am deploying this
in cdf, I am having this error
"The specified setting for the option GraphicsBoxOptions, ImageSize
cannot be used."
--
Murray Eisenberg ***@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Murray Eisenberg
2012-05-05 08:13:41 UTC
Permalink
Your code works perfectly as is for me (Mathematica 8.0.4).

You can even make a function with x as argument:

f[x_] := Manipulate[
Plot[Sin[i t], {t, 0, 10},
ImageSize -> Scaled[x]],
{i, 1, 5}]
Post by Pooja Tewari
Hi,
I am new to Mathematica and I have been stuck with this seemingly small issue for some time now -
x:=.5;
g = Manipulate[
Plot[Sin[i t], {t, 0, 10},
ImageSize -> Scaled[x]], {i, 1, 5}]
I want to assign the variable x to .5 and then use it in Manipulate function, which plot a graph of sin[i t] and imagesize should be scaled to x( which is already assigned). But when I am deploying this in cdf, I am having this error
"The specified setting for the option GraphicsBoxOptions, ImageSize cannot be used."
--
Murray Eisenberg ***@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Loading...