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

The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.

Summation Operation with Table inputs

RM_10517434
3-Visitor

Summation Operation with Table inputs

Hi, 

I'm trying to convert some excel sheets into mathcad,

this particular one uses the summation function for variables features to be included,

 

I've set up a table list to define the variables, these are calculated earlier in the document so I didn't want to simply input the values as they could change.

 

I'm having trouble with a fewof things

1. if i include beta.yi in the equation it displays the result as a matrix rather than a single answer

     a. I've managed to crowbar this to work with beta.y which as it is the same for both values (50 deg) to get a result but i'm aware that this isnt the correct final solution

2. the summation results are double what i am expecting, by tweaking the "n" value from 2 to 1 the results match but don't match what i understood how the function should work as

    a.      i=1           the starting value of the summation

    b      n (n=2)    the ending value of the summation where n>i

3. as i haven't defined any further values in the table i would expect that if n was set to 3 or above there would be no change to the values (as there is a multiplication by zero within those numbers) however im finding that as n increases the results do continue to change.

 

ive attached a copy of the worksheets

- in green the manual approach which shows the results im trying to achieve

- in yellow is the section where ive set beta to beta.y (non matrix) which shows the final results double what im expecting

- in orange where beta uses beta.yi from the table which returns the matrix reults

 

n.b, the original equation ive pasted into the sheet uses beta xi,yi these are to evaluate different cases (so arent used at the same time) 

 

Any help / advice would be great thanks (i'm probably not using the correct syntax)

but its not clear from the help files how to fix,

 

Richard, 

(struggling to upload the file but please see below for screenshots)

 

RM_10517434_1-1672930953277.png

RM_10517434_0-1672930928677.png

 

4 REPLIES 4
LucMeekes
23-Emerald III
(To:RM_10517434)

Do you realise that Prime indexes arrays (Matrices and Vectors) starting at 0? This is controlled by the built-in variable ORIGIN. If you want your arrays to start idexing at 1, you have to set ORIGIN to 1. This can be done via the menu, or by defining

ORIGIN := 1

at the top of the sheet.

Further should really attach the worksheet. For identifying indexing problems a picture doesn't suffice. You'll find an interface to upload your file below the typing panel, where it says:

LucMeekes_0-1672944271454.png

 

Success!
Luc

Hi Luc

Thanks for the reply, that would explain what i'm encountering, 

i hadnt realised thats what the origin controlled, i'd seen a few worked examples that used that function but none explained what it was for and all the help files i was looking at was to do with the summation function and not the table itself

 

yeah, i tried to upload the file (its only 26kb) but i was still waiting for it to finish uploading after 10 minutes so I got the post up 

(even now ive just tried to upload and its taking a ridiculous amount of time, i'll try a different machine in a bit)

 

But thanks again 🙂

Capture.JPG

Werner_E
25-Diamond I
(To:RM_10517434)

I guess that assuming that vectors start with index 1 by default was just one of the errors.

Another one was that you used the index i in the name of the vectors which you defined in the table.

 

But thats not necessary and Prime actually is using two completely different types of indices:

  • The literal index, which is simply part of the variable name and nothing you can use to increment or calculate with. keyboard short is "Ctrl + -"
  • The vector/matrix index (and thats what you need to calculate the sums). Keyboard short is "["

So here is an approach which is aware of the setting of ORIGIN and it also works OK no matter how many elements your vectors alpha, etc. consist of (because it uses "last(alpha)" which gives us the index of the last element in the vector alpha). Its also not necessary to define any variables or ranges "i" or "j".

Werner_E_0-1672997451084.png

Of course you can define a variable n:=last(alpha) first and then use n in the formula to better match the original template.

Also note that in

Werner_E_1-1672997651793.png
"y" is a literal index, but "i" is a vector index.

I noticed the beta.x is never used by your expression and the formula in the original template uses something like beta.x,y ...

 

Anyway, here is a second way to get the result, avoiding the index "i" altogether and utilizing Prime's feature of vectorization (note the arrow above the expressions).

Werner_E_2-1672997873260.png

Vectorization means that the vectors underneath are not multiplied using the vector dot product, but the multiplication is done element by element and the results are collected in a result vector. The sum symbols then sum up the elements in this result vector.

 

BTW, instead of

Werner_E_3-1672998196848.png

you could use the determinant

Werner_E_5-1672998261410.png

 

Sheet in P6 format attached

Announcements

Top Tags