Dear all,
I have a function u(t,x), which is dependent on both t and x. Now, i plotted a graph of u versus x, at various time points (i.e. i get several curves of u over x at different time points on the same plot).
The question is: how am i to find the gradient at a particular point on the graph? Let's say at u(t,2) and at all the time points?
I'm thinking of diff() and grad(). But what is the difference and how would i be able to set this up in my code?
Any help appreciated. Thankies!
Wendy
|
|
0
|
|
|
|
Reply
|
Wen
|
3/29/2010 10:03:09 PM |
|
"Wen Zhe " <wenzhe2092@hotmail.com> wrote in message <hor82t$e7r$1@fred.mathworks.com>...
> Dear all,
>
> I have a function u(t,x), which is dependent on both t and x. Now, i plotted a graph of u versus x, at various time points (i.e. i get several curves of u over x at different time points on the same plot).
>
> The question is: how am i to find the gradient at a particular point on the graph? Let's say at u(t,2) and at all the time points?
>
> I'm thinking of diff() and grad(). But what is the difference and how would i be able to set this up in my code?
>
> Any help appreciated. Thankies!
>
> Wendy
The functions, 'diff' and 'gradient', are considerably different. The 'gradient' function allows you to specify variable-length intervals within your two independent variables, t and x in this case, if you so choose. They do not have to be uniformly spaced apart. Also it returns both (all) components of a gradient calculation. However, be sure you read the description - the first component returned is for the second argument and visa-versa.
I can't be certain, but I suspect the approximations made by 'gradient' are of a higher than first order, possibly a cubic. If not, there are undoubtedly some third-order gradients available in the file exchange. I recall I wrote one for one of these threads quite some time ago, but I can't remember how to locate it now.
On the other hand 'diff' returns differences in only one direction - for you, in either the t direction or the x direction. Also it assumes that the corresponding spacing is always in unit-length intervals. In other words the values returned by 'diff' are strictly successive differences. Consequently there are one fewer of them in whatever direction it is taken than in the input variable, whereas the vector or matrix returned by 'gradient' is always the same size as its input argument.
Roger Stafford
|
|
0
|
|
|
|
Reply
|
Roger
|
3/29/2010 11:19:28 PM
|
|
Thanks for the reply Roger.
So which one would you recommend that i use? grad() or diff()?
Wendy
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <horci0$er4$1@fred.mathworks.com>...
> "Wen Zhe " <wenzhe2092@hotmail.com> wrote in message <hor82t$e7r$1@fred.mathworks.com>...
> > Dear all,
> >
> > I have a function u(t,x), which is dependent on both t and x. Now, i plotted a graph of u versus x, at various time points (i.e. i get several curves of u over x at different time points on the same plot).
> >
> > The question is: how am i to find the gradient at a particular point on the graph? Let's say at u(t,2) and at all the time points?
> >
> > I'm thinking of diff() and grad(). But what is the difference and how would i be able to set this up in my code?
> >
> > Any help appreciated. Thankies!
> >
> > Wendy
>
> The functions, 'diff' and 'gradient', are considerably different. The 'gradient' function allows you to specify variable-length intervals within your two independent variables, t and x in this case, if you so choose. They do not have to be uniformly spaced apart. Also it returns both (all) components of a gradient calculation. However, be sure you read the description - the first component returned is for the second argument and visa-versa.
>
> I can't be certain, but I suspect the approximations made by 'gradient' are of a higher than first order, possibly a cubic. If not, there are undoubtedly some third-order gradients available in the file exchange. I recall I wrote one for one of these threads quite some time ago, but I can't remember how to locate it now.
>
> On the other hand 'diff' returns differences in only one direction - for you, in either the t direction or the x direction. Also it assumes that the corresponding spacing is always in unit-length intervals. In other words the values returned by 'diff' are strictly successive differences. Consequently there are one fewer of them in whatever direction it is taken than in the input variable, whereas the vector or matrix returned by 'gradient' is always the same size as its input argument.
>
> Roger Stafford
|
|
0
|
|
|
|
Reply
|
Wen
|
3/31/2010 8:20:31 AM
|
|
|
2 Replies
461 Views
(page loaded in 0.024 seconds)
Similiar Articles: Finding gradient on curve - comp.soft-sys.matlabDear all, I have a function u(t,x), which is dependent on both t and x. Now, i plotted a graph of u versus x, at various time points (i.e. i get se... Shortest Distance between a point and a curve ? - comp.soft-sys ...Tangent edge lines - comp.cad.solidworks Finding gradient on curve - comp.soft-sys.matlab function for slope of regression line - comp.soft-sys.matlab ... Overlaying the curve onto an image - comp.soft-sys.matlab ...how to find gradient image... - comp.soft-sys.matlab Finding gradient on curve - comp.soft-sys ... gradient map can be applied to any image in Adobe Photoshop CS3. Curvature of a 3D implicit function - comp.soft-sys.matlab ...Starting with an implicitly defined surface, f(x,y,z) = 0, we wish to find the ... Finding gradient on curve - comp.soft-sys.matlab Curvature of a 3D implicit function - comp ... using lsqcurvefit to fit an ODE to data and finding parameters ...lsqcurvefit z(x,y) - comp.soft-sys.matlab Finding gradient on curve - comp.soft-sys.matlab using lsqcurvefit to fit an ODE to data and finding parameters ... Tangent edge lines - comp.cad.solidworkspolar plotting two lines - comp.soft-sys.matlab Finding gradient on curve - comp.soft-sys.matlab Tangent edge lines - comp.cad ... To find the Cartesian slope of the ... Implicit differentiation in matlab - comp.soft-sys.matlab ...Implicit differentiation in matlab - comp.soft-sys.matlab ... Finding gradient on curve - comp.soft-sys.matlab Curvature of a 3D implicit function - comp.soft-sys.matlab ... function for slope of regression line - comp.soft-sys.matlab ...Tangent edge lines - comp.cad.solidworks Finding gradient on curve - comp.soft-sys.matlab function for slope of regression line - comp.soft-sys.matlab ... polar plotting two lines - comp.soft-sys.matlabTangent edge lines - comp.cad.solidworks polar plotting two lines - comp.soft-sys.matlab Finding gradient on curve - comp.soft-sys.matlab Tangent edge lines - comp.cad ... lsqcurvefit error using matlab R2008a - comp.soft-sys.matlab ...lsqcurvefit z(x,y) - comp.soft-sys.matlab... 100x100 matrix) int_p = [10 10 10 0 0 0 1 1 1]; [new_p, error] = lsqcurvefit ... Finding gradient on curve - comp.soft-sys ... Finding the gradient of a curve? - Yahoo! AnswersBest Answer: If you haven't yet done both solving quadratic equations and differentiation, then you'll have to do it by plotting the graph and drawing ... GradientsFinding the gradient of a straight line or curve. ... 18th Jul 2012 NOTE: - Welcome to MathsRevision - we reach over 1 million users each month! 7/20/2012 12:02:14 PM
|