Message Boards Message Boards

0
|
7268 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Add several elements in a list

Posted 10 years ago

Hi,

i am new to Mathematica and would be glad if someone could help me. I am trying to add all elements from the alpha values {a55 to a516) in a new list. The result should always be 1. I am failing to get the relevant values

{a55 -> 0., a144 -> 0., a153 -> 0., a444 -> 0., a516 -> 1.}

for example ... thanks in advance

Here is a part of my list for better understanding

{{588.833, {a55 -> 0., a144 -> 0., a153 -> 0., a444 -> 0., 
   a516 -> 1.}}, {591.623, {a55 -> 0., a144 -> 5.98205*10^-9, 
   a153 -> 0., a444 -> 0., 
   a516 -> 1.}}, {594.522, {a55 -> 3.25107*10^-9, 
   a144 -> 5.49271*10^-9, a153 -> 4.53039*10^-9, 
   a444 -> 2.12099*10^-8, 
   a516 -> 1.}}, {597.534, {a55 -> 8.17124*10^-9, 
   a144 -> 1.48647*10^-8, a153 -> 1.17452*10^-8, 
   a444 -> 6.94263*10^-8, 
   a516 -> 1.}}, {600.662, {a55 -> 2.22368*10^-10, 
   a144 -> 3.86578*10^-10, a153 -> 3.16347*10^-10, 
   a444 -> 1.62874*10^-9, 
   a516 -> 1.}}, {603.913, {a55 -> 5.55368*10^-10, 
   a144 -> 9.54729*10^-10, a153 -> 7.86149*10^-10, 
   a444 -> 3.89039*10^-9, a516 -> 1.}}}
POSTED BY: Kuri Mon
3 Replies

Transpose[{Flatten@data[[All, 2]]}][[All, 1, 2]] // Total

POSTED BY: Tanel Telliskivi
Posted 10 years ago

thank you very much. That helped! :)

POSTED BY: Updating Name
  (*data={{588.833, {a55 -> 0., a144.....*)
  Total@Flatten@data[[All, 2]] /. (Rule[x_, y_] :> y)
   (* 6.333*)
POSTED BY: Nasser M. Abbasi
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