Hello. I generate a matrix of outcomes. Suppose we have 10,20,30 values. I need to delete unnecessary rows of the matrix. My idea is to multiply 10 by the second column, 20 by third column,, 30 by fourth column. After that I delete all rows which do not satisfy the condition. for n-1, we remove all rows where an element has the value more than 30, for n-2 more than 50, for n-3 more than 60. But I can't even get 10,20,30 multiplied to second, third and fourth columns. Please, help me. Thanks in advance!
Regards,
Alex
Alex,
Look at Select[].
If your lst is numbers and not strings:
Select[lst, #[[4]] <= 60 &]
Neil
There is extensive documentation on adding and taking rows and columns of matrices. Look at the part options and the matrix and vector operations guide.
For example,
lst[[All, 2]]
Is the second column. You can also set the second column with
lst[[All, 2]] = {....}
You need to Map the Delete:
Delete[4] /@ lst
or
Map[Delete[4], lst]
And how to add a column to specific place, for example, in the middle. ,this adds a column to the end
MapThread[Append , {sr11, Table[0, Length[sr11]]}] Insert dosent work for this case
Thank you so much for your reply. Could you please give me another hint on how to delete each forth element from the list.
{{0, 0, 0, 0}, {10, 0, 0, 10}, {0, 20, 0, 20}, mat12 = Delete[lst, 4]
This comand dosent work in this case.
Well I make some progress, the only questions I have now. How to delete rows which are more 60(forth column)?