mardi 21 avril 2020

create a list from another table making selection

I need to create a new list (newlist) from a previous table (oldtable) making a selection: I want to put in the new list the element in row 1 if the element in the same column and row 5 is equal one.

For example

oldtable=(50 30 20 40

1 0 1 0)

nelist=(50 20)

I wrote newlist = {}; For[i = i, i <= 10000, i = i + 1, en = oldtable[[1, i]]; If[oldtable[[5, i]] == 1, AppendTo[newlist, {en}], 0];]; newlist

but it does not work. Some help? Thanks.

Aucun commentaire:

Enregistrer un commentaire