0

I'm working with Mathematica, I begin by importing the data from some CSV files, and I store them under some variable names. For the moment let's assume we use:

sample1 = Sort[RandomReal[{0, 10}, {10, 2}]];
sample2 = Sort[RandomReal[{0, 10}, {10, 2}]];
sample3 = Sort[RandomReal[{0, 10}, {10, 2}]];

So, I want to do some calculations on the data individually, I was thinking of using a PopupMenu by "recalling" the defined variables and then I could do a linear fit and display both the data and the linear fit, and also find the highest value:

variables = Names["Global`*"];
PopupMenu[Dynamic[x], variables]
data=Dynamic[x];
lm = LinearModelFit[data, x, x];
Show[ListLinePlot[data, PlotRange-> All], 
Plot[lm[x], {x, 0, data[[Length[data], 1]]}]]
Peak = Max[data[[All, 2]]]

But the problem is that when i recall the variables, Mathematica only brings them as names and not the actual data list.

For the moment I'm trying also to store different calculations on a bigger list that would go on storing the values for the calculations:

Data = {};

(This bit would be outside, with the data importing probably, just to define the list)

AppendTo[Data, {Normal[lm], Peak}]

I'm also trying to store the name of the set that's selected, so that's another challenge... Would anyone know how could I solve this issue?

I do realize that it's a pretty specific question (sorry!), but it could be used for other things too! I think...

Thanks!

edwincool2
  • 13
  • 2
  • It seems like many users fall into the hole of just having to use every animated desktop-published dynamic manipulate they see. And they immediately can't make it work. What if you scrapped all that and just did the calculations? Can you get that to work? And save all the aggravation spent trying to figure the do-dads out? I do understand the answer is almost always "But now that I've seen it I just HAVE to use it." Sorry. Note: I did try to figure it out for you. You are ONLY giving PopupMenu the names, not the values, and it seems likely that is why it won't work for you. I doubt this helps. – Bill Jul 03 '14 at 23:09
  • Sure, I've done the required calculations, but I need to keep changing the values of the imported data. When I tried using the values instead of the names, the popup menu displayed the whole (or at least a part) list of data and being a lot of datapoints then it gets pretty messy; besides, it doesn't work that well, as I would just be selecting a list, without knowing to which specific sample does it correspond to. – edwincool2 Jul 04 '14 at 00:52

0 Answers0