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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Simple variable (range or vector) question

jwhitwam
1-Visitor

Simple variable (range or vector) question

I'm having a problem figuring out how to do some math on a subset of a vector.  I have some data that I want to store in a variable (range or vector).  I want to be able to perform some simple math on portions of that variable, but it's not working the way I'd expect.

(I apologize, I don't know how to add mathcad notation in this forum)

Example.

I have 4 elements I'm storing in a variable called row (row = 1,3,7,15) using range variables ii=0..3

I want to take the 2nd through 4th element and subtract off the 1st through 3rd element and store that in a new variable which would have the result of newrow = 2,4,8

I thought I could just do the following

jj=1..3

kk = 0..2

newrow[kk = row[[jj - row[[kk

but I get an error saying jj should be an integer.

What am I missing?

Thanks!

ACCEPTED SOLUTION

Accepted Solutions
MJG
18-Opal
18-Opal
(To:jwhitwam)

5 REPLIES 5
MJG
18-Opal
18-Opal
(To:jwhitwam)

How about this?

jwhitwam
1-Visitor
(To:MJG)

That looks like it's what I want to do.  Now the question is, why does it have to be done that way?  Why doesn't my way work as it looks to be doing basically the same thing?

MJG
18-Opal
18-Opal
(To:MJG)

In your attempt, Mathcad was trying to apply the entire range jj to each element of newrow.  For example, the way you wrote the equation, Mathcad tried to calculate the following for the first element (kk=0) of newrow:

LucMeekes
23-Emerald III
(To:jwhitwam)

Another option is to use the submatrix function:

Luc

Werner_E
25-Diamond I
(To:jwhitwam)

If you are not using the crippled Express version, you may also consider using a user defined function:

Announcements

Top Tags