Message Boards Message Boards

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

How to append lists?

Posted 3 years ago

I have the 3 lists

t={1,2,3,4}
ch1={15,16,17,18}
ch2={23,24,25,26}

from which I want to create a new list

{{1,15,23},{2,16,24},{3,17,25},{4,18,26}}

How to do that?

Neither Join, Append nor Catenate help with it.

Any idea?

POSTED BY: Ehud Behar
4 Replies
Posted 3 years ago
Transpose@{t, ch1, ch2} // Prepend[{"t", "ch1", "ch2"}] // Export["test.csv", #] &
POSTED BY: Rohit Namjoshi
Posted 3 years ago

Hi Ehud,

Transpose@{t, ch1, ch2}
(* {{1, 15, 23}, {2, 16, 24}, {3, 17, 25}, {4, 18, 26}} *)
POSTED BY: Rohit Namjoshi
Posted 3 years ago

Thanks! Can you also show me how to export this new list to a csv file that has the structure

t,ch1,ch2
1,15,23
2, 16, 24
3, 17, 25
4, 18, 26

?

POSTED BY: Ehud Behar
Posted 3 years ago

check out MapThread[]

POSTED BY: Mike Besso
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