Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- how do I sum all elements of an array?

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-31-2018
03:15 PM

12-31-2018
03:15 PM

how do I sum all elements of an array?

I need to sum all elements of an array. Is there a function that does this?

Labels:

6 REPLIES 6

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-02-2019
07:04 AM

01-02-2019
07:04 AM

Re: how do I sum all elements of an array?

Hi,

Yes there is a function. It is on the ribbon at Maths | Operators And Symbols | Operators | Calculus.

Cheers Terry

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-03-2019
01:58 AM

01-03-2019
01:58 AM

Re: how do I sum all elements of an array?

Hi,

This for an "array" rather than just a "vector"

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-03-2019
04:59 AM

01-03-2019
04:59 AM

Re: how do I sum all elements of an array?

The summation symbol Terry pointed you to only works with column and row vectors (matrices with either just one column or just one row).

In case you are looking for the sum of all elements of an arbitrary matrix, here are two shorter routines which do the job:

And here is a way to sum up recursively all scalars even in multiple nested matrices (for whatever that may be worth).

Worksheet in format P5 attached

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-03-2019
07:09 AM

01-03-2019
07:09 AM

Re: how do I sum all elements of an array?

You could also do the following for matrices (though not nested matrices):

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-03-2019
11:47 AM

01-03-2019
11:47 AM

Re: how do I sum all elements of an array?

Or, to be independent of ORIGIN and of the size of the array/Matrix:

Success!

Luc

Prime 3.1 file attached

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-03-2019
08:58 PM

01-03-2019
08:58 PM

Re: how do I sum all elements of an array?

OK, here sure are many ways to skin a cat.

Even though DJV doesn't show any interest, here are two more ways to achieve the desired result.

Personally I still would prefer my first one, "SumAll1". It also seems to be the fastest, followed by the recursive "SumAll3".

Worksheet in Format P5 attached.