0
$\begingroup$

I am using a command like this

data = Transpose[{t1, Table[z1[[i]], {i, 1, 10}]}] //Tableform

There will be N lists t1,z1[[1]],...z1[[10]] I would like to transpose these lists to save in a table format such that I can export in a data file in N+1 columns. Could anyone please shed some light on this problem? Thanks in advance.

$\endgroup$
  • 2
    $\begingroup$ Allways try to provide a complete, working example, that is as minimal as possible. This has the adavntage of helping you spot the bug by yourself and helps other users in understanding the problem. $\endgroup$ – Gladaed May 29 at 13:43
2
$\begingroup$

Transpose only works on matrices that are rectangular in both dimensions, in which they are getting transposed.

z1[i_] = z1[i, #] & /@ Range[3]
t1 = Range[3]
data = Transpose[Prepend[t1]@Table[z1[i], {i, 1, 10}]] // TableForm

works perfectly fine. Please note that in most cases it is more sensible to store data in lists, not Grids, TableForms etc. since it will be easier to access. If you need to access the data of a simple TableForm or similar constructs it can help to use "// InputForm". It shows that TableForm[x] internally is TableForm[x] meaning you can access its data by doing TableForm[x][[1]]. It does not just replace the head of x.

Edit: You seem to be confused about Lists and their elements. You might benefit from looking at the respective documentation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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