Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
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)
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:
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 🙂
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:
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".
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
"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).
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
you could use the determinant
Sheet in P6 format attached