Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

Thanks.

share|improve this question
    
related Q/A –  kguler Apr 12 '13 at 13:42
    
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"). –  Yves Klett Apr 12 '13 at 13:48
    
Have a look at Export and Table in the documentation. –  Sjoerd C. de Vries Apr 12 '13 at 14:32
    
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/…; 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!) –  Derrick Apr 12 '13 at 15:15
    
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. –  Sjoerd C. de Vries Apr 12 '13 at 17:56

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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