[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multi Column Data file to plot, gradient plot, or gradient of gradie
From: |
Przemek Klosowski |
Subject: |
Re: Multi Column Data file to plot, gradient plot, or gradient of gradient plot |
Date: |
Tue, 30 Mar 2004 16:27:02 -0500 (EST) |
On Mar 26, 2004, at 1:39 PM, Timothy Milstead wrote:
> xy plot the gradient of the data as lines and then finally the
> gradient of the gradient as xy plot.
And Paul Kienzle suggested:
This is the simple formula for a gradient,
dy/dx ~= (y_i+1 - y_i) / (x_i+1 - x_i)
d2y/dx2 ~= (y_i+1 - 2y_i - y_i-1) / (x_i+1 - x_i)^2
You can come up with more sophisticated approximations.
and came up with this implementation
plot(x(1:end-1),diff(y)./repmat(diff(x),1,columns(y)));
plot(x(2:end-1),diff(y,2)./repmat(diff(x(2:end)).^2,1,columns(y)));
OK, so we have relatively simple formulas, and an implementation that
is not only nonobvious, but I think might also be incorrect.
At first, I thought that there should be built-in differential
operators (gradients, Laplacians, etc), but then, I thought that there
are multiple details---possibly higher-order corrections, etc, that
would be hard to provide in a simple and general way. Then, it
occurred to me that the 'filter()' function is great for constructing
differential operators. For instance,
dydx = filter([-1,1],1,y) ./ filter([-1,1],1,x)
d2ydx2 = filter ([1,-2,1],1,y) ./ filter ([1,-2,1],1,x)
(I gloss over what are the values of X that I calculate the derivatives
in, but you get the general drift).
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- Multi Column Data file to plot, gradient plot, or gradient of gradient plot, Timothy Milstead, 2004/03/26
- Re: Multi Column Data file to plot, gradient plot, or gradient of gradient plot, Joe Koski, 2004/03/27
- Re: Multi Column Data file to plot, gradient plot, or gradient of gradient plot, Paul Kienzle, 2004/03/27
- Re: Multi Column Data file to plot, gradient plot, or gradient of gradient plot,
Przemek Klosowski <=
- Re: Multi Column Data file to plot, gradient plot, or gradient of gradient plot, Henry F. Mollet, 2004/03/27