COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Help with Summing the elements in an array

• Email
• Follow

```I have a 145x1 size matrix and I'm trying to sum all of those elements within the matrix. An example would be a matrix like [ 1 2 3 4] would equal 10 because 4+3+2+1=10.

I've searched a while and any help would be great.
```
 0

See related articles to this posting

```On Sat, 25 Sep 2010 21:12:04 +0000 (UTC), "Lee "
<lsouthwood09@yahoo.com> wrote:

>I have a 145x1 size matrix and I'm trying to sum all of those elements within the matrix. An example would be a matrix like [ 1 2 3 4] would equal 10 because 4+3+2+1=10.
>
>I've searched a while and any help would be great.

doc sum
```
 0

```How did you search?  I cannot believe that you didn't come across the SUM function during your search, unless you didn't search using the terms which describe the problem.  Try this:

docsearch('sum')
```
 0

```Matt Fig wrote:
> How did you search?  I cannot believe that you didn't come across the
> SUM function during your search, unless you didn't search using the
> terms which describe the problem.  Try this:
>
> docsearch('sum')

or the inimitable

lookfor sum

:)

--
```
 0

3 Replies
379 Views

Similar Articles

12/11/2013 10:01:32 PM
[PageSpeed]

Similar Artilces:

Help with the last element in an array
Hi All, I have a file like: (test1) SA blk: 2 pg: 4 col: 5 time: 4 SB blk: 4 pg: 4 col: 6 time: 4 SC blk: 5 pg: 3 col: 3 time: 2 SD blk: 1 pg: 2 col: 8 time: 9 SE blk: 8 pg: 0 col: 3 time: 10 SF blk: 2 pg: 1 col: 6 time: 11 SG blk: 5 pg: 9 col: 0 time: 45 I am trying to generate the output: SA - SB - SC SB - SC - SD SC - SD - SE SD - SE - SF SE - SF - SG But i am getting: SA - SB - SC SB - SC - SD SC - SD - SE SD - SE - SF Here i am missing out the last SE - SF - SG. The array in the code below (@seen) has SE - SF and SF - SG. I need to combine these and delete SF to get SE - SF - SG. ...

Novice trying to SUM array elements from query results.
I thought that this was going to be super easy (and it probably is), but I couldn't figure it out. I have results from a MySQL query which include PartNumber, Qty, Cost, and Price. In one part of the report, I want to only display Sum/Total info. As an example, let's say there are 5 rows of data, and I want to know only the sum total of \$result["qty"] from all 5 rows. I was expecting to use array_sum(), but have come to discover that this only sums all the elements of a single array. Any pointers? ~Mo ..oO(Mo) >I thought that this was going to be super easy (and it pr...

1-D Array of 3 elements to waveform(DBL) help needed
Hi, I am getting this error:"These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Context Help window to see what data type is required.The type of the source is 1-D array of cluster of 3 elements.The type of the sink is Waveform(DBL)."I have tried converting into a 1-d array but the error remains I am somewhat out of ideas on how to solve this problem. Any help is greatly appreciated thank you. Get Frequency.vi: http://forums.ni.com/attachments/ni/170/334939/1/Get Frequency.vi The sink is a waveform datatype, so I&...

deleting elements of one array by comparing it to the elements of another array
I m a newbie to LabVIEW and I have a very basic question. &nbsp; I have two arrays. The first array contains a certain set of elements &nbsp; For e.g.&nbsp; 1 2 3 4 5 6 &nbsp; The second array has another set of elements &nbsp; For eg. 2 5 6 &nbsp; Now I want to delete the elements 2 5 6 from the first array and plot the first array with the deleted elements on a waveform graph. &nbsp; Can anybody help me out? &nbsp; Thanks and regards. Hello,you could do something like this:<img src="http://forums.ni.com/attachments/ni/170/231758/1/Example_BD.png"...

Sorting a Hash of Arrays by an Element in the Array
Hello all- I have seen many old questions where people ask if this can be done, and many responses where people claim it is not possible. However, I believe I have done it successfully and that it is quite easy: for my \$key (sort {\$hash{\$a}->[0] <=> \$hash{\$b}->[0]} keys %hash) { print "\$key\n"; } Am I missing something??? It looks as if it can be done to me. Thanks, Alf Alf McLaughlin wrote: > for my \$key (sort {\$hash{\$a}->[0] <=> \$hash{\$b}->[0]} keys %hash) { > print "\$key\n"; > } > Am I missing something??? It looks as ...

help generating an array of array with malloc or calloc
Hi ! I would like to generate an array of type char[n][5]; I just dont really figure out how I could do it with malloc or calloc.. I mean.. I know how to allocate a simple array with both of them; but when it comes to a 2 dimension array.. I'm stuck.. I mean.. if I ask for char** array = malloc(5*n*sizeof(char));, it'll return a void*, not a void**.. anyone have an idea ? Eric Boutin wrote: > > Hi ! I would like to generate an array of type char[n][5]; > > I just dont really figure out how I could do it with malloc or calloc.. I > mean.. I know how to allo...

Need help on AoH or array or any other think that might help!
Hello good people out there. I need to write a perl script that will parse the log and generate the following output: a flat text file in the following format: customer_name| product_category|item_description|cost An example log file could be: Pedro|groceries|apple|1.42 Nitin|tobacco|cigarettes|15.00 Susie|groceries|cereal|5.50 Susie|groceries|milk|4.75 Susie|tobacco|cigarettes|15.00 Susie|fuel|gasoline|44.90 Pedro|fuel|propane|9.60 1.A report of the total revenue resulting from each customer. 2.A report for each customer showing how much of their spending went to each category. With the abov...

Address of a specific element: an Array containing Array References ...
Friends: I have a syntax question, and I have put together this contrived example (with running comments), to demonstrate the line of code I need adjusted. Sorry for the verbosity. ############################################################## # @tableCellData = will be used to store 2 anonymous array references. # @table = will be used to store addresses of array *elements* (not of arrays). ############################################################## my (@table, @tableCellData); ##################################################### # Insert 2 anonymous array...

Updating single array element seems to send array out of kilter.
Hi all, Forgive me for my perl inadequacies, but hopefully it is a very simple solution that I am striving for. The pseudocode of what I am attempting to do is as follows: 1. Read contents of a file and parse data into 2 arrays - person and count. 2. Print out status of current arrays 3. Randomly choose one person from array 1 and increment the count by 1, updating the associated array element. 4. Print out new status of arrays. The issue I face is that the print in task 2 nicely places each entry on a single line, with no use of "\n". After running task 3, the print in task 4 no...

Array help!!
Hi, Please help. Here is the situation. I've tried to create a radio button when clickeck by a user, a function will automatically check all checkbox in a form. I've tried to do this using a for loop but I did not have any luck. My intention was when a user click on the radio button, checkbox for testa,testb,testc,and testd will be checked. <form name="myForm"> check all<input type="radio" name=alert value=all onclick="checkAll(this)"> <font color="oliveDrab" size=1%>testa </font><input type="checkbox&quo...

Summing an array.
Hello all, I've got a little problem I've been stuck on for a few days now, and I was hoping to get at least a little guidance to a viable solution. My issue involves the summation of an array in two ways. The array is the used as the output of model plasma measurement device to express the number of particle strikes at a specific position at a certain energy- per-charge value: X-Coordinate Y-Coordinate Count Energy-per-Charge X and Y are both integers that range from 0 to 63, Count is a floating point value, and Energy-per-Charge is a floating point value logarithmica...

Array sum
Hello, I have an Array that looks like this: Array ( [0] => Array ( [0] => Number 1 [1] => 3 ) [1] => Array ( [0] => Number 2 [1] => 3 ) [2] => Array ( [0] => Number 3 [1] => 2 ) ) How can I Sum numbers from this array to get 8 as result of this array. TNX zoidberg wrote: > How can I Sum numbers from this array to get 8 as result of this array. You can reference the inner values by using as many indices as the...

help array
Hi guys ! my problem: I have obtain a something like: A is an array that must contain other array of numbers Example= A={a,b,c} a=[1:10] b=[11:20] c=[21:30] I need a for loop that first enter in a and read all elements, second enter in b and read all element... What is the correct istruction to do it??How can i do it? lello wrote: > Hi guys ! > my problem: > I have obtain a something like: > A is an array that must contain other array of numbers > Example= > A={a,b,c} > a=[1:10] > b=[11:20] > c=[21:30] > > I need a for loop that first enter in a and read ...

(DOM)Compute the sum of width of elements contained in blockleve element
Hi. I know that it is hard problem (as hard as CSS and HTML layouting rules apply), but maybe someone has some code or idea how to start it. For now i know i will cssQuery: <URL:http://dean.edwards.name/my/cssQuery/> My point of interest is all elements inside <div class="bodycontent"> [...] </div>, so to get direct descendant elements i will use: var tags = cssQuery("div[class='bodycontent'] > *"); My question is about returned elements (which represent html tags) - do they have some property which will indicate the actual width which they ...

help on an array problem
The following is my source code; ----------------------------------------------------------- library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; use IEEE.std_logic_unsigned.all; entity EGC is generic(M : natural := 4); Port ( input1 : in std_logic_vector(15 downto 0); output1 : out std_logic_vector(15 downto 0)); end EGC; architecture Behavioral of EGC is subtype vector16 is std_logic_vector(15 downto 0); type vector_M_16_Out is array(0 to M) of vector16; signal out1: vector_M_16_Out; begin out1(0) <= input1; proc0 : process(out1, input1) begin --o...