Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Why does this element by element assignment not work?
Solved! Go to Solution.
"length" gives you the number of entries in a vector (BTW "rows" would yield the same result).
That way your loop reads
and "loops" just from 3 to 3. The only value "i" is assigned is 3.
Its the same as
So you just define element with index 3 of your vector. If you do so, by default the other entries with lower indices are set to zero, like
In this example the value of ORIGIN was not changed and is at its default value 0. So the element with index 3 is the fourth vector entry. In your sheet you obviously had set ORIGIN to 1.
So what you meant was
The loop start at 1, which is the value of ORIGIN in your sheet, and ends at length(e)=3 (which is only the index of the last vector element if ORIGIN is set to 1)
A better approach would be
because its independent from the setting of ORIGIN.
The "last" function returns the index of the last vector element, taking into account the value of ORIGIN.
"length" gives you the number of entries in a vector (BTW "rows" would yield the same result).
That way your loop reads
and "loops" just from 3 to 3. The only value "i" is assigned is 3.
Its the same as
So you just define element with index 3 of your vector. If you do so, by default the other entries with lower indices are set to zero, like
In this example the value of ORIGIN was not changed and is at its default value 0. So the element with index 3 is the fourth vector entry. In your sheet you obviously had set ORIGIN to 1.
So what you meant was
The loop start at 1, which is the value of ORIGIN in your sheet, and ends at length(e)=3 (which is only the index of the last vector element if ORIGIN is set to 1)
A better approach would be
because its independent from the setting of ORIGIN.
The "last" function returns the index of the last vector element, taking into account the value of ORIGIN.
Of course. Silly me. I actually have used that construct a couple of times earlier, it just hasn’t become part of “muscle memory” yet.
Thank you for quick reply!
No problem.
You may consider closing the thread if there are no follow up questions.
For future questions I would suggest that you attach your worksheet (even though its just as small as here) and also state which version of Prime you are using.
