Differentiation in 2D for Non Uniformly Distributed Data

25 次查看(过去 30 天)
Hello, My problem is quite simple, I think, but I cannot find a solution.
I have a 2d scatter plot of an electric field. So basically I have a nx3 matrix, let's call it M, where the 2 first columns are the x and y coordinates, and the 3rd column is a value between 0 and 1 Volts.
So I basically plot this as: scatter(M(:,1),M(:,2),5,M(:,3));
I would like to calculate the second order spatial derivative of this electric field in 2 Dimensions. But I don't know how to do that. I tried using the gradient function, but this doesn't work. I think this is due to the fact that my 2D space is not uniformly distributed (it was exported by a FEA in COMSOL).
Thank you in advance for your help.
Julia
  2 个评论
Alberto
Alberto 2014-4-10
编辑:Alberto 2014-4-10
Hi Julia:
in a function like that, second order derivatives is the Hessian matrix. There are formulas for obtain the second order partial derivatives, I`m afraid you will have to implement them by yourself.
For example, for the first derivative, and you have the nodes x_0, x_1 and x_2:
f'(x_1)= [f(x_2) - f(x_0)]/(x_2 - x_0)
This first derivative aproximation doesn't need the spaces between the nodes. Once you have the functions derived, you can derived again in the same variable or the other one.
Julia
Julia 2014-4-10
Hello,
Thank you for your quick response!
Indeed, I should compute the Hessian matrix. However, I will get a 2x2 Matrix. How do I plot this? Do I plot the norm of the matrix?
Thank you for your help!

请先登录,再进行评论。

回答(3 个)

Andrew Newell
Andrew Newell 2014-4-10
编辑:Andrew Newell 2014-4-10
Before using finite difference formulae, you should use TriScatteredInterp to create a gridded data set. You can't use the gradient function because it applies to functions, not fixed data points. Once you have obtained the Hessian, how you plot it depends on what you want to learn. For example, you might want to look at each component separately, or you might be interested in the norm.

Gypaets
Gypaets 2015-12-18
I've written a function which calculates first and second order spatial derivatives: trigradient2
You can get the second order derivatives approximation with
[~, ~, Uxx, Uyy, Uxy]=trigradient2(M(:,1),M(:,2),M(:,3));

jennifer
jennifer 2024-11-11,13:48
Differentiating 2D data when it’s not uniformly distributed can be challenging because the data points are spaced unevenly, making standard methods less accurate. Specialized techniques, like using adaptive grids or interpolation, help achieve smoother results. For projects that involve complex data visualization, such as in animations, working with professionals can make a real difference. Partnering with a Video Animation Company in Dubai ensures accurate and visually engaging representation of data, helping audiences understand insights more effectively.

类别

Help CenterFile Exchange 中查找有关 Fractals 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by