3
$\begingroup$

As far as I know, the CDF can be used to distribute projects in which you can interactively evaluate the projects without need to have Mathematica.

Recently I notice that the files in the Demonstration Project contain CDF files in which the code is not at all included. If you check this Radial Engine example and download the CDF file you will see that the code is not anywhere in the file and to get the code you have to download it separately.

How can that be done? Is it just simply delete the input cell and keep the output cell and then export the file as standalone CDF or something else has to be done.

Thank you

$\endgroup$
2
  • $\begingroup$ Is the CDFDeploy function the answer? How closely is this topic related: How to create a “standard” CDF programmatically?. Also, when you click File/CDFExport you can pick the source to be the selection. $\endgroup$
    – Kuba
    Commented Apr 8, 2016 at 10:16
  • $\begingroup$ @Kuba it is related and thanks for mentioning it. $\endgroup$ Commented Apr 9, 2016 at 17:27

1 Answer 1

8
$\begingroup$
  1. Completely define your demonstration in a Manipulate or DynamicModule by making use of the Initialization and/or SaveDefinitions options.
  2. Copy and paste only the output cell into a new (or existing) notebook.
  3. Export this notebook as CDF.

For example, the following Manipulate is completely defined by using Initialization. So by performing steps 2 and 3 a CDF without code can be created.

Manipulate[
 Plot[a g[x] + c, {x, -10, 10}, PlotRange -> {-22, 22}],
 {a, -2, 2}, {c, -5, 5},
 Initialization :> {g[x_] := x Sin[x]}
 ]

Hope this helps.

$\endgroup$
3
  • $\begingroup$ The code certainly does not show when opening the CDF in Mathematica but if you select the cell and choose Convert To InputForm, everything shows. And while more than a bit cryptic, the commands are visible when the CDF is opened up in a text editor. $\endgroup$
    – JimB
    Commented Apr 8, 2016 at 2:53
  • $\begingroup$ Let me clarify my previous comment: the Convert To InputForm shows the code when I follow the above instructions on my own CDF's. However, the Radial Engine example won't show the code when attempting to use Convert To InputForm. So I think there must be something that restricts the showing of the code during the process that converts a candidate CDF document which ends up on the Demonstration Project. $\endgroup$
    – JimB
    Commented Apr 8, 2016 at 3:12
  • $\begingroup$ @JimBaldwin Could be using Enterprise CDF for the Demonstration Project. $\endgroup$
    – Edmund
    Commented Apr 8, 2016 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.