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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Vector and Range Variable

ValeryOchkov
24-Ruby IV

Vector and Range Variable

See the picture - Vector and Range Variable mixture:

Val

http://twt.mpei.ac.ru/ochkov/v_ochkov.htm
40 REPLIES 40

On 9/10/2009 5:01:04 PM, philipoakley wrote:

>What is wrong is the need to manually
>manage the
>linkage between the location in the data
>array and
>an ancillary vector holding the unit
>based sample
>locations.

As opposed to what? Manually managing the linkage between the location in the data array and an ancillary range variable holding the unit based sample locations?

>I think you misread/misunderstood what I
>had tried
>to say.

Maybe.

> It is using the regular A[i
>where i is a
>range variable for iteration across a
>data set I
>meant. Thus both A[0.3s and A[i with
>i:0s,0.1s;1.9s would be acceptable, as
>ways of
>accessing the data.

You can't access a vector using 0.1s. It's not an index. Or are you proposing that if I use 0.1s Mathcad works out it's the second value in the sequence, and then sets the index to 1? How does it know which range variable to use unless you tell it? If you have to tell it the name of the range variable and the value, how is that fundamentally any better than using match with your times held in a vector?

I think this comes back to the same argument we have had before. In fact it illustrates my (and others) point. People get into trouble when they use range variables for anything other than indexing and maybe setting the ranges for graphing. More often than not that's because they think they should behave like vectors, but they are not vectors. Even if you changed this particular behavior so that it worked like it was a vector, they will still behave differently in other ways.

If you use range variables only for indexing, and vectors for everything else, what you want to do works just fine right now (using match).

Richard
StuartBruff
23-Emerald III
(To:RichardJ)

On 9/10/2009 5:28:07 PM, rijackson wrote:
== If you use range variables only for indexing,
and vectors for everything else, what you want to
do works just fine right now (using match).

I think lookup matches the intent somewhat nearer
... or at least it would if it returned a quantity
value instead of just a numerical value.

Has anybody reported a problem with lookup not
returning a value with units? Or have I made a
mistake somewhere?

Stuart
RichardJ
19-Tanzanite
(To:StuartBruff)

On 9/10/2009 5:55:02 PM, stuartafbruff wrote:
>On 9/10/2009 5:28:07 PM, rijackson
>wrote:
>== If you use range variables only for
>indexing,
>and vectors for everything else, what
>you want to
>do works just fine right now (using
>match).
>
>I think lookup matches the intent
>somewhat nearer
>... or at least it would if it returned
>a quantity
>value instead of just a numerical value.

For a matrix, yes, but for a vector I would say it's six of one and half a dozen of the other.

>Has anybody reported a problem with
>lookup not
>returning a value with units?

I haven't

>Or have I
>made a
>mistake somewhere?

Not that I can see. It's a bug.

Richard
PhilipOakley
5-Regular Member
(To:StuartBruff)

On 9/10/2009 5:55:02 PM, stuartafbruff wrote:
>On 9/10/2009 5:28:07 PM, rijackson
>wrote:
>== If you use range variables only for
>indexing,
>and vectors for everything else, what
>you want to
>do works just fine right now (using
>match).
>
>I think lookup matches the intent
>somewhat nearer
>... or at least it would if it returned
>a quantity
>value instead of just a numerical value.
>
>Has anybody reported a problem with
>lookup not
>returning a value with units? Or have I
>made a
>mistake somewhere?
>
>Stuart

You can however select the value at 2.001s (based
on CTOL) or at 1/30 min
... which is as one would hope to achieve with
direct indexing of a vector that has an associated
x-axis unit-based range definition.

One would expect that a read function to bting in
data would also be possible
READ_DATA(file, y-units, sample-start-with-units,
sample-interval-with-same units)

We should already have a function to return a
range definition for a vector anyway!
i := rangeOf(vector)
so why not
t := rangeUnitsOf(vector)
to extract that metadata.

It would also help "solve" the problem of the FFT
& fft's x-axis units (which are different) [one
of those Elephant in the Room problems]

Philip Oakley
PhilipOakley
5-Regular Member
(To:RichardJ)

On 9/10/2009 5:28:07 PM, rijackson wrote:
>On 9/10/2009 5:01:04 PM, philipoakley
>wrote:
>
>>What is wrong is the need to manually
>>manage the
>>linkage between the location in the data
>>array and
>>an ancillary vector holding the unit
>>based sample
>>locations.
>
>As opposed to what? Manually managing
>the linkage between the location in the
>data array and an ancillary range
>variable holding the unit based sample
>locations?

Yes. I.e. as opposed to such manual error prone and labour intensive methods of maintaining an ancillary vector of index values.


>
>>I think you misread/misunderstood what I
>>had tried
>>to say.
>
>Maybe.
>
>> It is using the regular A[i
>>where i is a
>>range variable for iteration across a
>>data set I
>>meant. Thus both A[0.3s and A[i with
>>i:0s,0.1s;1.9s would be acceptable, as
>>ways of
>>accessing the data.
>
>You can't access a vector using 0.1s.
>It's not an index.

Oh yes you can. You are (in this case) thinking as a mathematician based on current mathcad implementation. I can easily look up the temperature at (hh:mm:ss) 3:45:21.3 from a data logger - that indexes directly into the data table as required, and can/should return the vaklue with units attached, just as the user has no need to know if the logger was set to 10Hz, 20Hz, or 1000Hz. the indexed location has the same 'unit'ed time code.

A range variable is the implicit method such data is created with when analytic values are prepared. e.g. creating a sine wave of temperature variation over time.

>Or are you proposing
>that if I use 0.1s Mathcad works out
>it's the second value in the sequence,
>and then sets the index to 1? How does
>it know which range variable to use
>unless you tell it? If you have to tell
>it the name of the range variable and
>the value, how is that fundamentally any
>better than using match with your times
>held in a vector?
>

>The part that is fundamentally better
>I think this comes back to the same
>argument we have had before. In fact it
>illustrates my (and others) point.
>People get into trouble when they use
>range variables for anything other than
>indexing and maybe setting the ranges
>for graphing.

The reason they get into trouble is that the intuitive expectations are not implemented.

And there are two faults with the implementation. You are concentrating on the other one.
a) Indexing is only allowed via integer values, fractions and reals are not allowed...
b) Indexing is not allowed via units (e.g. value at 3.ft) Such indexing currently has no concept of the users data sampling points in the unit space.
[c] also, confounding array indexing issues, range definition issues, and their unteraction/usage ! 😉

These become confounded when users attempt to access at say location 0.25 (no units, because they haven't used units before... [excel, c, matlab, basic...]).

The key to distinguishing case (a) from (b) is the presence of a unit[dimension] flag, whether an SI dimension or a mathcad extension [currency, angle, userUnit1, userUnit2...]

>More often than not that's
>because they think they should behave
>like vectors, but they are not vectors.
>Even if you changed this particular
>behavior so that it worked like it was a
>vector, they will still behave
>differently in other ways.
>
>If you use range variables only for
>indexing, and vectors for everything
>else, what you want to do works just
>fine right now (using match).
>
>Richard

Stuart has a point about properly introducing the 'sequence' concept, which includes the representation for ranges [often it is the representation that is at issue, not the implementation - see Tom's comments].

There should be no problems for a user to have her/his data ('y-axis) automatically associated with the corresponding sampling meta-data ('x-axis') and be processed directly using that meta-dat based indexing, rather than implementation and storage based indexing.

Philip Oakley

On 9/11/2009 4:53:19 AM, philipoakley wrote:

>Yes. I.e. as opposed to such manual
>error prone and labour intensive methods
>of maintaining an ancillary vector of
>index values.

Why is a vector of x values (I assume you mean x values, because I don't recall ever seeing anyone actually maintain a vector of index values) any more error prone and labor intensive than a range variable of x values?


>Oh yes you can. You are (in this case)
>thinking as a mathematician based on
>current mathcad implementation. I can
>easily look up the temperature at
>(hh:mm:ss) 3:45:21.3 from a data logger
>- that indexes directly into the data
>table as required, and can/should return
>the vaklue with units attached, just as
>the user has no need to know if the
>logger was set to 10Hz, 20Hz, or 1000Hz.
>the indexed location has the same
>'unit'ed time code.

How? If you are given a time and want to get the corresponding temperature the first thing you have to do is turn the time into an index, and then use that to get the temperature. There is no other way.

>A range variable is the implicit method
>such data is created with when analytic
>values are prepared. e.g. creating a
>sine wave of temperature variation over
>time.

It's a method of doing it. One method, if you want equally spaced x, and if the numbers are calculated rather than read in (i.e. real data).

>The reason they get into trouble is that
>the intuitive expectations are not
>implemented.

I disagree. It is because they think a range variable holds a vector of values, and it does not.

>And there are two faults with the
>implementation. You are concentrating on
>the other one.
>a) Indexing is only allowed via integer
>values, fractions and reals are not
>allowed...

Well, of course. A vector has a certain number of entries. How would you index those except with integers? A range variable takes on a certain number of values. How would you index those except using integers? If I define a range variable x:0,1;10, whats the 0.5th value?

>b) Indexing is not allowed via units
>(e.g. value at 3.ft) Such indexing
>currently has no concept of the users
>data sampling points in the unit space.

Same question as above. What's the (2*ft)th value of x?

>These become confounded when users
>attempt to access at say location 0.25

Location 0.25? I have a vector with three entries: 1, 2, 3. What's the value at index 0.25?

>There should be no problems for a user
>to have her/his data ('y-axis)
>automatically associated with the
>corresponding sampling meta-data
>('x-axis') and be processed directly
>using that meta-dat based indexing,
>rather than implementation and storage
>based indexing.

But you already can. You have to store the x data somehow. You can store it as a vector, or, in certain limited cases as a range variable, or as the first column of a two column matrix. If you store it as a vector you just use

Y[match(value,X)

It can't get much simpler than that. I suppose you could make the match implicit somehow:

Y[(value,X)

But you can't do it without using two pieces of information: the name of whatever holds the x values, and the x value of interest. That is true regardless of how you store x. You can't just write

Y[value

Richard
PhilipOakley
5-Regular Member
(To:RichardJ)

On 9/11/2009 8:11:00 AM, rijackson wrote:

..
> If you
>store it as a vector you just use
>
>Y[match(value,X)
>
>It can't get much simpler than that. I
>suppose you could make the match
>implicit somehow:
>
>Y[(value,X)
>
>But you can't do it without using two
>pieces of information: the name of
>whatever holds the x values, and the x
>value of interest. That is true
>regardless of how you store x. You can't
>just write
>
>Y[value
>
>Richard

Which is where I disagree, you should be able to write

Y[value

when value has a unit[dimension].
If value has no unit, then integer access is required.

The value of range variables, as currently implemented, is that the step size and start value are provided as a basis for their use in defining such data access.

Philip Oakley
(haven't looked at Stuart's code yet, not at a V14 PC)

On 9/11/2009 9:57:51 AM, philipoakley wrote:

>Which is where I disagree, you should be
>able to write
>
>Y[value

I have:

x1=(0.1,0.2,0.3,0.4)
x2=(0.3,0.4,0.5,0.6)
y=(10,11,12,13)

What's y[0.3 ?

Richard
PhilipOakley
5-Regular Member
(To:RichardJ)

On 9/11/2009 10:33:54 AM, rijackson wrote:
>On 9/11/2009 9:57:51 AM, philipoakley
>wrote:
>
>>Which is where I disagree, you should be
>>able to write
>>
>>Y[value
>
>I have:
>
>x1=(0.1,0.2,0.3,0.4)
>x2=(0.3,0.4,0.5,0.6)
>y=(10,11,12,13)
>
>What's y[0.3 ?
>
>Richard
you have no units[dimensions], so what is the
question?


Philip Oakley

On 9/11/2009 1:04:15 PM, philipoakley wrote:
>On 9/11/2009 10:33:54 AM, rijackson
>wrote:
>>On 9/11/2009 9:57:51 AM, philipoakley
>>wrote:
>>
>>>Which is where I disagree, you should be
>>>able to write
>>>
>>>Y[value
>>
>>I have:
>>
>>x1=(0.1,0.2,0.3,0.4)
>>x2=(0.3,0.4,0.5,0.6)
>>y=(10,11,12,13)
>>
>>What's y[0.3 ?
>>
>>Richard
>you have no units[dimensions], so what
>is the
>question?

I really don't get where you are trying to go with this. You said you should be able to use Y[value. I gave you an example of exactly that and asked how it would work. What have units got to do with it? If you want units,

x1=(0.1,0.2,0.3,0.4)*s
x2=(0.3,0.4,0.5,0.6)*s
y=(10,11,12,13)*kg

What's y[0.3*s ?

I fail to see how the units change anything. The fact remains that you can't index into Y by just subscripting with an x value from an unspecified set of x values.

We must be talking at cross purposes here, but I really don't see what you are driving at. If someone else can see where we are getting confused, please enlighten us (or me, anyway)

Richard
SteenGroðe
6-Contributor
(To:mzeftel)

hmm... got to try to remember this. I can remember way back when I started using Mathcad I got very frustrated not being able to index out of range.
I think it has to be possible due to the fact that it is necessary when thinking mathematically (aka not in numbers)

Steen Gro�e
Announcements

Top Tags