Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: from gradient to field
Date: Tue, 25 Oct 2011 07:20:32 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 29
Message-ID: <j85o00$ku1$1@newscl01ah.mathworks.com>
References: <j7rue6$gsu$1@newscl01ah.mathworks.com> <j7s8ol$ppj$1@newscl01ah.mathworks.com> <j85m7o$g1a$1@newscl01ah.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1319527232 21441 172.30.248.37 (25 Oct 2011 07:20:32 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 25 Oct 2011 07:20:32 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:747053

"Arseny Kubryakov" <arskubr@gmail.com> wrote in message <j85m7o$g1a$1@newscl01ah.mathworks.com>...
> 
> >   Once you know the value of G at some particular point, you can find its value at any other point by taking the line integral of the given gradient along any path between the two points.  If G is truly a gradient, meaning that its curl must be identically zero, the line integral value will be independent of the path taken.
> > 
> >   This means you should be able to construct a two-dimensional G by first taking a cumulative integral of the gradient along some straight line containing the particular point, and then for each discrete point evaluated along this line, take a cumulative integral along an orthogonal line.  This would give you the value of G at a 2D mesh of points.  (Of course if you are working in three dimensions it will require one additional level of integration along the third dimension.)
> > 
> >   Matlab's 'cumtrapz' is such a cumulative integration function, or for higher order integration there are cumulative integration routines available in FEX.  For example I have one that does third order approximation at:
> > 
> 
> > Roger Stafford
> 
> Dear Roger! Thanks a lot You for your answer.
> But I am not sure that I understood it clearly. What exactly I should put into cmtrapz? May be I should explain my problem more detail:
> So, I have FX and FY, that can be computed from F as
> [FX,FY] = gradient(F)

Take a fix point in 2D, X0, another point (X), and any curve C(x) that links X0 to X, then

F(X) = F(X0) + integral_curve dot (G(x),t(x)) dl(x)

t(x) is a tangential vector to the curve C(x). G(x) is the gradient.

If you choose the curve as going east-west then north-south, you'll see it a sum of two integrals that can be calculated by two trapz as Roger indicates.

This assume that G(x) is irrotational vector field (any gradient field is irrotational, if it does not have any significant numerical error).

A more reliable way is writing the gradient equation in PDE form and solve it using (sparse) matrix.

Bruno