I have some code in Mathematica which shows a colored plot, where the coloring depends on data values. I would like to make this into an interactive application that accepts two inputs:

  1. data, a list of data points.
  2. PocetDat, an integer parameter.

I know little about CDF, but i don't see how I can get inputs or table inputs from the users. Further, I want the users of the application to only see the inputs and the final plot -- no code.

data = 
  {-0.003, 0.002, 0.008, 0.014, -0.026, -0.036, -0.042, -0.010, -0.000, 
   -0.014, -0.013,  0.048, 0.014, -0.035, -0.023, 0.025, 0.001, -0.002, 
    0.050, 0.053,  0.031, -0.045, 0.003, 0.052, 0.066, -0.040,  0.016, 
   -0.054, -0.040, -0.042, -0.018, -0.034, -0.032, -0.021,  0.008, -0.007};
PocetDat = 912; 
KorelCiara = 2*Sqrt[1/PocetDat]; 
PRange = 1.2*Max[{data, KorelCiara}];
  DiscretePlot[data[[i]], {i, 1, Length[data]}, 
    ExtentSize -> Full, 
    ColorFunction -> Function[x, If[Abs[data[[x]]] > KorelCiara, Red, Blue]],  
    ColorFunctionScaling -> False], 
 Plot[{KorelCiara, -KorelCiara}, {x, 0, Length[data]}],  
 PlotRange -> {-PRange, PRange}]
  • $\begingroup$ But with .cdf's there are restrictions: you cannot use input fields and cannot read from files. What you can do is to import data from a (publicly accessible) website. This may be the best option. $\endgroup$
    – bill s
    Dec 15, 2013 at 7:06
  • $\begingroup$ I want to do something like that: secretzone.sktipy.sk/data.php Paste in Input some values from Excel .. it transforms to Mathematica table and I can working with this numbers. As user you know nothing what code do - i can count basic sums or else .. and this i like to do with Mathematica - have 1 input, button to start and after user saved some values it compute something. $\endgroup$ Dec 15, 2013 at 9:01

1 Answer 1


There are few things here to consider. First of all if you have some plans for future robust application reading out live data from hard drive, say, or arbitrary user input - then consider Mathematica Enterprise Edition where CDF can be more powerful.

But I think your case is very simple. You just need data input from user in the typical Manipulate interface. There are many ways to do this - especially for pure numerical values. But you have to think about convenience for users of the process of data entry. My favorite method is Locator - because it is interactive and editable. Demonstration Project has many examples to offer, you should search there, but 1st consider examples I give below. There are other ways of course. Consider for example a Slider and then 2 buttons to add and delete a point. Slider itself is better than InputField IMHO because it already has input field built-in

enter image description here

BTW apps at Demonstration Project address your other question - they are clearly examples where user sees only interface and not code. It is easy. When you deploy CDF cellect only cell that contains interface, do not select the code cell.

enter image description here

enter image description here

  • $\begingroup$ Hello, thanks but I don't need Slider. I need to add many values in InputField and counting for example Sum of them. Can you do something with your value 0.208? It is possible to saved more values in 1 input? Can compute Sum of this numeric values? $\endgroup$ Dec 15, 2013 at 9:05
  • $\begingroup$ @MartinZvolenský I really recommend looking through the source code of these Demonstrations (and many others at Demonstration project). They obviously deal with data that user inputs and do analysis on them - isn't it what you need? Also it is not clear is user adding data 1-by-1 or many at once? If it is many at once - are you imagining user tediously typing all those decimal digits you showed in your example? Exact details of user action are not clear to me. $\endgroup$ Dec 15, 2013 at 9:15
  • $\begingroup$ Yes it is what I need, but i nothing found :) $\endgroup$ Dec 15, 2013 at 9:22
  • $\begingroup$ Many at once. This values are output from other software. If you have just one example it would be very helpful for me. $\endgroup$ Dec 15, 2013 at 9:24
  • $\begingroup$ @MartinZvolenský Why not just import that file from another software with Import command? $\endgroup$ Dec 15, 2013 at 12:01

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.