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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

15-Moonstone

## Is it possible to create noncontinuous range variable?

Hi all

MC15

I want to create range variable like i:=1,2,3,5 to use it in iterations like

a.i:=i for example

Now I`ve to use index vector i={1 2 3 5}T inside program loop for this.

Is it possible to create noncontinuous range variable?

1 ACCEPTED SOLUTION

Accepted Solutions
23-Emerald III
(To:ifomenko)

While we're waiting for Stuart's request to be finally implemented in Prime version N...

you don't necessarily need to program, if you can live with...Well it's basically what Fred described above:

Success!
Luc

15 REPLIES 15
23-Emerald I
(To:ifomenko)

The definition for a range variable precludes this:  first, second , , last.  If you need a noncontiguous step as you've described, create a vector of integers rather than a range variable.  Then you can use the integers in that vector as indices in your loop.

19-Tanzanite
(To:ifomenko)
 Is it possible to create noncontinuous range variable?

A range variable does not store a list of values, it stores the start, the increment, and the end. So no, that is not possible.

15-Moonstone
(To:RichardJ)

Very sad it will simplify worksheet a lot

21-Topaz II
(To:ifomenko)

You may store the indexes, known a priori and with variable integer  increment, in a vector and then, with a loop, recall, associating them to an integer index of an element of a vector in a matrix on which to do the calculations.

Attached there is an example quite complicated.

15-Moonstone
(To:-MFra-)

I know about vector possibility, but in this case I need to use a loop instead of ellegant one row string))

21-Topaz II
(To:-MFra-)

You may store the indexes, known a priori and with variable integer  increment, in a vector V and then, with a loop index j, recall k=V[j], and then work on the vector U[k]

The previous  attached file is the answer to another similar problem solved some months ago (proposed by aimtaz)

15-Moonstone
(To:-MFra-)

21-Topaz II
(To:ifomenko)

Simplified version:

24-Ruby III
(To:ifomenko)

24-Ruby III
(To:ValeryOchkov)

23-Emerald II
(To:ifomenko)
 Igor Fomenko wrote: Hi all MC15 I want to create range variable like i:=1,2,3,5 to use it in iterations like a.i:=i for example Now I`ve to use index vector i={1 2 3 5}T inside program loop for this. Is it possible to create noncontinuous range variable? Many thanks in advance

Not as you. I have a long standing request to allow such a feature, including by extending the concept of a sequence to allow arbitrary lists of values, such as 1,2,3,5 or (1..3),5.  We can already do this in a programming for loop, so this change woukd mean we could do the same thing at worksheet level using the := operator.

Stuart

15-Moonstone
(To:StuartBruff)

23-Emerald III
(To:ifomenko)

While we're waiting for Stuart's request to be finally implemented in Prime version N...

you don't necessarily need to program, if you can live with...Well it's basically what Fred described above:

Success!
Luc

15-Moonstone
(To:LucMeekes)

Thank you very much LucMeekes.I forgot about this opportunity at all))).40 years old is not so good as 20)))

23-Emerald III
(To:ifomenko)

Which can be presented a little smaller by using i for the vector and . for its index (You'll have to use [Ctl-Shft-K] to enter the . symbol):

Announcements