http://www.mathworks.com/matlabcentral/newsreader/view_thread/313599
MATLAB Central Newsreader  from gradient to field
Feed for thread: from gradient to field
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Fri, 21 Oct 2011 14:09:10 +0000
from gradient to field
http://www.mathworks.com/matlabcentral/newsreader/view_thread/313599#855815
Arseny Kubryakov
Dear all!<br>
<br>
Right now I am working on reconstructing dynamic topography of the ocean from geostrophic currents. So in fact, I have one random field G that is the gradient of another random field S. <br>
<br>
How can I, using matlab, compute initial field from it's known gradient?<br>
<br>
Thanks a lot for your help

Fri, 21 Oct 2011 17:05:25 +0000
Re: from gradient to field
http://www.mathworks.com/matlabcentral/newsreader/view_thread/313599#855828
Roger Stafford
"Arseny Kubryakov" <arskubr@gmail.com> wrote in message <j7rue6$gsu$1@newscl01ah.mathworks.com>...<br>
> Right now I am working on reconstructing dynamic topography of the ocean from geostrophic currents. So in fact, I have one random field G that is the gradient of another random field S. <br>
> <br>
> How can I, using matlab, compute initial field from it's known gradient?<br>
          <br>
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.<br>
<br>
This means you should be able to construct a twodimensional 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.)<br>
<br>
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:<br>
<br>
<a href="http://www.mathworks.com/matlabcentral/fileexchange/19152">http://www.mathworks.com/matlabcentral/fileexchange/19152</a><br>
<br>
Roger Stafford

Tue, 25 Oct 2011 06:50:32 +0000
Re: from gradient to field
http://www.mathworks.com/matlabcentral/newsreader/view_thread/313599#856160
Arseny Kubryakov
<br>
> 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.<br>
> <br>
> This means you should be able to construct a twodimensional 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.)<br>
> <br>
> 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:<br>
> <br>
<br>
> Roger Stafford<br>
<br>
Dear Roger! Thanks a lot You for your answer.<br>
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:<br>
So, I have FX and FY, that can be computed from F as<br>
[FX,FY] = gradient(F)<br>
The task is to solve an inverse problem so to go from FX,FY to the field F.<br>
Thaks for your attention!

Tue, 25 Oct 2011 07:20:32 +0000
Re: from gradient to field
http://www.mathworks.com/matlabcentral/newsreader/view_thread/313599#856165
Bruno Luong
"Arseny Kubryakov" <arskubr@gmail.com> wrote in message <j85m7o$g1a$1@newscl01ah.mathworks.com>...<br>
> <br>
> > 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.<br>
> > <br>
> > This means you should be able to construct a twodimensional 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.)<br>
> > <br>
> > 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:<br>
> > <br>
> <br>
> > Roger Stafford<br>
> <br>
> Dear Roger! Thanks a lot You for your answer.<br>
> 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:<br>
> So, I have FX and FY, that can be computed from F as<br>
> [FX,FY] = gradient(F)<br>
<br>
Take a fix point in 2D, X0, another point (X), and any curve C(x) that links X0 to X, then<br>
<br>
F(X) = F(X0) + integral_curve dot (G(x),t(x)) dl(x)<br>
<br>
t(x) is a tangential vector to the curve C(x). G(x) is the gradient.<br>
<br>
If you choose the curve as going eastwest then northsouth, you'll see it a sum of two integrals that can be calculated by two trapz as Roger indicates.<br>
<br>
This assume that G(x) is irrotational vector field (any gradient field is irrotational, if it does not have any significant numerical error).<br>
<br>
A more reliable way is writing the gradient equation in PDE form and solve it using (sparse) matrix.<br>
<br>
Bruno