Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Convert list of rules to matrix' topicStudent Support Forum > General > Archives > "Convert list of rules to matrix"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
07/10/13 12:13pm

In[1]:= SS = {{A -> 46437., B -> 25091.7, C -> 96620.4, D -> 13557.5}, {A -> -217685., B -> 161155., C -> 104625., D -> -119304.}, {A -> -0.278772, B -> 0.351899, C -> 0.425027, D -> 0.818112}, {A -> 0.492067, B -> -0.439226, C -> -0.386384, D -> 1.28467}, {A -> 0.125003, B -> 1., C -> 0., D -> 0.}};

First always look at the FullForm.

In[2]:= FullForm[SS]

Out[2]= {{A -> 46437., B -> 25091.7, C -> 96620.4, D -> 13557.5}, {A -> -217685., B -> 161155., C -> 104625., D -> -119304.}, {A -> -0.278772, B -> 0.351899, C -> 0.425027, D -> 0.818112}, {A -> 0.492067, B -> -0.439226, C -> -0.386384, D -> 1.28467}, {A -> 0.125003, B -> 1., C -> 0., D -> 0.}}

Second write a substitution rule that matches the structure of that.

In[3]:= SS /. Rule[_, x_] -> x

Out[3]= {{46437., 25091.7, 96620.4, 13557.5},
{-217685., 161155., 104625., -119304.},
{-0.278772, 0.351899, 0.425027, 0.818112},
{0.492067, -0.439226, -0.386384, 1.28467},
{0.125003, 1., 0., 0.}}

URL: ,

Subject (listing for 'Convert list of rules to matrix')
Author Date Posted
Convert list of rules to matrix kevin.w 07/10/13 05:51am
Re: Convert list of rules to matrix Bill Simpson 07/10/13 12:13pm
Re: Convert list of rules to matrix Peter Pein 07/11/13 07:36am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic