Skip to main content
1-Visitor
May 18, 2011
Question

Calculating a Scalar in a Matrix

  • May 18, 2011
  • 3 replies
  • 8301 views

I have a matrix, where each column in the matrix represents a different calculation. I need to create a new column in the matrix where I sum the values in the first column and compare it to each individual value in the second column. I'm having trouble programming this in a for loop because Mathcad keeps telling me the value must be a matrix of scalar elements. I've attached an example worksheet. Let me know if you have any questions.

thanks!!

3 replies

23-Emerald I
May 18, 2011

You're not doing a summation.

I don't understand the double loop!

Fred

12-Amethyst
May 18, 2011

Anne

You are summing an element ( TEST[k,1) , change to summing the column ( TEST<1> )

23-Emerald I
May 18, 2011

Wayne Reid wrote:

Anne

You are summing an element ( TEST[k,1) , change to summing the column ( TEST<1> )

Since Anne is developing the first column row by row as she iterates through the matrix the sum of the lolumn will change each time through. Need to be careful!

12-Amethyst
May 18, 2011

Hi Fred,

I know, I think that might be what she wants though, can't really tell as her example is just a test and not the real thing?

19-Tanzanite
May 18, 2011

It's not clear to me what you want (or, judging from the other replies, to Fred or Wayne either). The text of your post implies that you have an existing matrix, and want to subserviently sum column 1, and compare the sum to column 2, so the sum does not change for each comparison. But your worksheet implies that you are creating the matrix at the same time that you are doing the sum and comparison, in which case the sum is different for each comparison. Which is correct?

amaurer1-VisitorAuthor
1-Visitor
May 18, 2011

Richard,

I want to compare the additive total of Column 1 to each element in Column 2. Therefore, the sum should not change, only the "flag" (i.e. either 1 or 0). I'm trying to build a "failure" flag into my programming loop in order to determine when the individual values in Column 2 exceed the total of Column 1. I hope this clarifies the question.

amaurer1-VisitorAuthor
1-Visitor
May 18, 2011

The sum does not change (i.e. total for Column (1) = 1775). This is the value I need to compare to each element in Column (2) (i.e. 1775 vs. 2 vs. 3 vs. 4, etc.). Am I not doing this?