Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #457

Re: Plotting y(i)-y(i-1) vs x(i)

From Christoph Bersch <usenet@bersch.net>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: Plotting y(i)-y(i-1) vs x(i)
Date 2011-07-20 22:17 +0200
Organization 1&1 Internet AG
Message-ID <j07d49$hk5$1@online.de> (permalink)
References <3e1c6c29-4dbb-41eb-9d2c-b39433087638@glegroupsg2000goo.googlegroups.com>

Show all headers | View raw


On 20.07.2011 19:55 Victor wrote:
> 
> On Wednesday, July 20, 2011 1:03:32 AM UTC-6, Christoph Bersch wrote:
>> y = 0
>> oldy = 0
>> diff(x) = (oldy = y, y = x, y - oldy)

> In what part of documentation can I read about how this function
> works. I don't quite understand the relationship between oldy, y and x.

About user-defined function, see section 13.4 "User-defined variables
and functions".
The expression (a, b, c) is called "serial evaluation" and explained in
sec. 13.2.2 "Binary Operators":

Serial evaluation occurs only in parentheses and is guaranteed to
proceed in left to right order. The value of the rightmost subexpression
is returned.

So, to come back the my code, the evaluation order is
1. oldy = y # shift the previous y value to oldy
2. y = x    # y now hold the current value
3. y - oldy # return the difference

Christoph

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Find similar


Thread

Re: Plotting y(i)-y(i-1) vs x(i) Victor <victor.prosolin@gmail.com> - 2011-07-20 10:55 -0700
  Re: Plotting y(i)-y(i-1) vs x(i) Christoph Bersch <usenet@bersch.net> - 2011-07-20 22:17 +0200

csiph-web