Message Boards Message Boards

0
|
3638 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Exported Data Showing up in Several Excel Sheets, need only one

 Clear["Global'*"];
 kresmod1 =
  Table[nut = 46; khi = 25; ro2 = 3400; kmrs = 70; kisu = 1.2;
   kmp = 1.0;
   kccc1 = 40; k23 = 16; kvp = .04; kc = 21; nc = 5; km1 = 24; nm1 = 3;
   km2 = 46; nm2 = 4; kv1 = 24; nv1 = 9; kv2 = 200; nv2 = 4; k32 = 18;
   n32 = 9; a = .5;
   odec = -(a c[t]) - (
     kccc1 c[t] (1 - 1/((c[t]/kv1)^nv1 + 1)))/((f3[t]/kv2)^nv2 + 1) - (
    kmrs c[t])/((fs[t]/km2)^nm2 + 1) + (khi nut)/((c[t]/kc)^nc + 1);
  odefm = -(a fm[t]) + (kmrs c[t])/((fs[t]/km2)^nm2 + 1) -
    kisu fm[t] - kmp fm[t] o2[t];
  odefs = kisu fm[t] - a fs[t];
  odemp = kmp fm[t] o2[t] - a mp[t];
  odeo2 = -(kmp fm[t] o2[t]) - kres fs[t] o2[t] +
    ro2/((o2[t]/245)^9 + 1);
  odef2 = -(a f2[t]) - k23 f2[t] (1 - 1/((c[t]/k32)^n32 + 1)) + (
    kccc1 c[t] (1 - 1/((c[t]/kv1)^nv1 + 1)))/((f3[t]/kv2)^nv2 + 1);
  odef3 = -(a f3[t]) + k23 f2[t] (1 - 1/((c[t]/k32)^n32 + 1)) -
    kvp f3[t];
  odevp = kvp f3[t] - a vp[t];
  vars = {c[t], f2[t], f3[t], fm[t], fs[t], mp[t], o2[t], vp[t]};
  solution =
   NDSolve[{Derivative[1][c][t] == odec,
     Derivative[1][f2][t] == odef2, Derivative[1][f3][t] == odef3,
     Derivative[1][fm][t] == odefm, Derivative[1][fs][t] == odefs,
     Derivative[1][mp][t] == odemp, Derivative[1][o2][t] == odeo2,
     Derivative[1][vp][t] == odevp, c[0] == 30, f2[0] == 100,
     f3[0] == 100, fm[0] == 50, fs[0] == 50, mp[0] == 0, o2[0] == 100,
      vp[0] == 100}, vars, {t, 0, 31}];
  vars /. solution /. t -> 31, {kres, 0, 2, .25}]
kresmod1 // TableForm
Export["modfile.xls", kresmod1]
SystemOpen["modfile.xls"]
Having a small problem exporting the data generated by my code out to excel. It exports just fine, but the data is spread out over several sheets. I've been trying to figure out how to get either excel to consolidate them together or for mathematica to export it as a single sheet. Any suggestions?
POSTED BY: Josh Wofford
2 Replies
Awesome, thanks for the assist Sean.
POSTED BY: Josh Wofford
To create a single sheet excel file, you normally give Export a list of lists containing your data. That is, you give it a 2D list. 

If you give it a 3D list, that is a list of lists of lists, then it will have to make multiple sheets. 

What do you see when you run Dimensions on your data. Is it a 2D or a 3D list?
kresmod1 // Dimensions

kresmod1 is a 3D list of values. You can use Flatten to reduce the dimensions down to two.
Flatten[kresmod1, 1]
POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract