Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Here is the issue, I've tried every which way to get this summation to work, but it keeps giving me an "undefined variable" error. I tried adding the matrix vector operator "[" to indicate the "i" index, but that didn't seem to work either.
Can someone point me in the right direction here?
Solved! Go to Solution.
1) You used the wrong equal sign when you tried to define alpha and lambda. You must use the assignment (:=) and not the boolean (the bold equal sign)
2) At least lambda must also be assigned the correct unit (1/s) as otherwise you get an error because the exponent lambda*t2 must be dimensionless. You may consider assigning alpha a correct unit, too, so the outcome Gamma.total can be shown with the correct unit.
Gamma normally will be shown in W. If you want MeV/s to be seen, you simply overwrite W by the unit you want to see and Prime adjusts the rest as needed.
Hi,
Matrix indexing is first element is numbered zero by default. Your summation interval is 1 to 11.
Two options.
One change the indexing to 0 to 10
Two set the worksheet variable ORIGIN := 1
Cheers
Terry
Hi,
You also need to add the indexing [i to each instance of alpha and lambda in the summations
Cheers
So, I added '[' index i's to all of the lambda and alpha terms and changed the summation bounds from i=0 to 10, but MATHCAD is still giving me the same error.
Your first approach can't work the way you had set it up but there might be a simples way doing it using vectorization
Your second approach should work if you have set ORIGIN to 1 and if you used the correct subscript (matrix index as you said you have done) and if the various P.. and t.. are defined above.
The error message you describe ("undefined variable") indicates that the problem is not a wrong ORIGIN setting but rather a problem with Prime's infamous auto-label feature. Check if all lambda and all alpha are labelled the same (either "variable" or "-").
It's hard to debug just a picture and so it would be a good idea if you attach your worksheet as well.
If you don't use the latest version of Prime you should also state which version you are using.
I'm not really sure what you mean by "setting ORIGEN:=1." I attached my worksheet and made corrections to the indexing range. The problem starts on page #4. I'm using Prime 5.0.
1) You used the wrong equal sign when you tried to define alpha and lambda. You must use the assignment (:=) and not the boolean (the bold equal sign)
2) At least lambda must also be assigned the correct unit (1/s) as otherwise you get an error because the exponent lambda*t2 must be dimensionless. You may consider assigning alpha a correct unit, too, so the outcome Gamma.total can be shown with the correct unit.
Gamma normally will be shown in W. If you want MeV/s to be seen, you simply overwrite W by the unit you want to see and Prime adjusts the rest as needed.
That is exactly what the problem was. I knew it had to have been something simple that I had overlooked. Thank you for taking a look for me.
Addendum:
ORIGIN is a system variable which determines what the number of the first element of a vector would be. By default its value is 0. You can change the value of ORIGIN in the calculation menu or simply by typing ORIGIN:=1 (or an other value) on top of your worksheet.
To avoid the hassle in your sum you can replace the start value by ORIGIN and as stop value you may use last(lambda) or last(alpha) as shown in the first sum in the picture below. This makes the calculation independent of the current value of ORIGIN.
As mentioned in my first replay there is also a way to avoid the index i by using vectorization. Its an ORIGIN-independent calculation, too. This is shown here:
Worksheet in P5 format attached.