Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
from gradient to field

Subject: from gradient to field

From: Arseny Kubryakov

Date: 21 Oct, 2011 14:09:10

Message: 1 of 4

Dear all!

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.

How can I, using matlab, compute initial field from it's known gradient?

Thanks a lot for your help

Subject: from gradient to field

From: Roger Stafford

Date: 21 Oct, 2011 17:05:25

Message: 2 of 4

"Arseny Kubryakov" <arskubr@gmail.com> wrote in message <j7rue6$gsu$1@newscl01ah.mathworks.com>...
> 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.
>
> How can I, using matlab, compute initial field from it's known gradient?
- - - - - - - - - - -
  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:

 http://www.mathworks.com/matlabcentral/fileexchange/19152

Roger Stafford

Subject: from gradient to field

From: Arseny Kubryakov

Date: 25 Oct, 2011 06:50:32

Message: 3 of 4


> 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)
The task is to solve an inverse problem so to go from FX,FY to the field F.
Thaks for your attention!

Subject: from gradient to field

From: Bruno Luong

Date: 25 Oct, 2011 07:20:32

Message: 4 of 4

"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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us