Very new to Mathematica. Used the code to solve for the response of a system of spring mass dampers but would like to export the data to Excel.

Dyn = NDSolve[{Response[[1]] == 0, Response[[2]] == 0, 
               Response[[3]] == 0, Response[[4]] == 0, x[0] == 0.1, x'[0] == 0, 
               phi[0] == 0, phi'[0] == 0, xf[0] == 0, xf'[0] == 0, xr[0] == 0, 
               xr'[0] == 0}, {x, phi, xf, xr}, {t, 0, 1}];

Plot[Evaluate[{x[t], phi[t], xf[t], xr[t]} /. Dyn], {t, 0, 1}, PlotRange -> All]

Basically want x, phi, xf and xr against time, only in Excel.


  • $\begingroup$ related Q/A $\endgroup$ – kglr Apr 12 '13 at 13:42
  • $\begingroup$ Yes, do you want to export the data or the Plot ted graphics? In any case, there already are answers around (see right side of this page under "Linked"). $\endgroup$ – Yves Klett Apr 12 '13 at 13:48
  • $\begingroup$ Have a look at Export and Table in the documentation. $\endgroup$ – Sjoerd C. de Vries Apr 12 '13 at 14:32
  • $\begingroup$ Thanks for the reply. I had a look at both of those in the documentation. I only managed to get an export of a graphic working. Which is not what I want. I would like the data. I also tried making a table following these "forums.wolfram.com/mathgroup/archive/2010/Jan/msg00268.html" guidlines and some other things, then exporting. But no luck, I've never used mathermatica before and was given the part of the code I've post here (I don't even really know how that bit works!) $\endgroup$ – Derrick Apr 12 '13 at 15:15
  • $\begingroup$ Why do you export the plot if you only need the data? Make a table of the data (that's the part within Evaluate's brackets). If you really read The documentation on Table that shouldn't be much trouble. $\endgroup$ – Sjoerd C. de Vries Apr 12 '13 at 17:56

This is really, really basic stuff and you really, really should be able to figure this out yourself using the built-in documentation system.

Anyways, assuming your differential equation is OK (which it might not as Response is undefined in this snippet and everything is equal to 0) you would make a table like this:

t = Table[{x[t], phi[t], xf[t], xr[t]} /. Dyn, {t, 0, 1, 0.05}];

and export it like this:

Export["filename.xls", t]

or, in one step:

Export["filename.xls",Table[{x[t], phi[t], xf[t], xr[t]} /. Dyn, {t, 0, 1, 0.05}]

Change the value of 0.05 to in/decrease the number of steps.

| improve this answer | |

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