cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Extraction and sum of values in an array

BPP
7-Bedrock
7-Bedrock

Extraction and sum of values in an array

Hello everyone

As I can extract values from different columns of a matrix and get the total sum. Attached is a sample sheet with what I do.

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:BPP)

Here you are.

If you don't like to use the vector notation when you provide the arguments, you may use the stack command where you can edit the arguments more convenient.

1.png

View solution in original post

5 REPLIES 5
Werner_E
24-Ruby V
(To:BPP)

It would be easy to write a function for your yellow expressions, but concerning your green expressions you demand too much for at least two reasons:

1.png

1) A user defined function can't have a variable number of arguments. You have to decide whether RESULT() should have two or just one argument.

2) Life would be much easier if we could agree on that the second function argument always indicates the columns in the matrix and not one time the columns and the other time one additional row. Furhermore - how should RESULT() know in the screenshot above that you mean just the firrst column?

Of course it would be possible to implement RESULT() in such a way that in case the second argument is not a valid column number but a string that it meant as an additional row indicator and column(s) should default to 1 in the special case. But I would strongly advise against that kind of (very) special rule.

So something like the following is easy to implement, but your green examples -- harder (2nd argument is row, too) up to impossibe (function with either one or more arguments).

2.png




BPP
7-Bedrock
7-Bedrock
(To:Werner_E)

The expressions in green, were just a curiosity. Do not know why but I came to mind if it was possible to introduce the variables that way.

It was my mistake to introduce this curiosity in the question . Concerning the terms in yellow, would greatly appreciate if you could help me with these expressions, because for my is difficult create a routine for that.

Werner_E
24-Ruby V
(To:BPP)

Here you are.

If you don't like to use the vector notation when you provide the arguments, you may use the stack command where you can edit the arguments more convenient.

1.png

StuartBruff
23-Emerald II
(To:Werner_E)

Nice worksheet, Werner.

I wonder whether it might be better to return NaN if there are no valid sums, rather than 0 which could be a legitimate sum?

Stuart

BPP
7-Bedrock
7-Bedrock
(To:BPP)

So it possible enter the arguments of the two ways.

Thank you very much Werner and also to Stuart for your suggestion.

Top Tags