Borrar filtros
Borrar filtros

How to calculate the gradient of 3D velocity

28 visualizaciones (últimos 30 días)
Xinchen Zhang
Xinchen Zhang el 21 de Ag. de 2020
Respondida: Bjorn Gustavsson el 21 de Ag. de 2020
Let's say the "wind.mat" in matlab. I was supposed to get 9 tensors of the velocity gradients, du/dx, du/dy, du/dz, dv/dx, dv/dy, dv/dz, dw/dx, dw/dy, dw/dz.
I calculate following dudx=gradient(u)./gradient(x), dudy=gradient(u)./gradient(y) ...
but the gradient(y)=0 and gradient(z)=0 for this equally-spaced mat, results in a infinity value in the du/dy tensor.
Anyone can help me to correct the script for the gradient calculation?
  1 comentario
KSSV
KSSV el 21 de Ag. de 2020
Read the documentation properly......if you provide an array, you will get all the components at once.

Iniciar sesión para comentar.

Respuesta aceptada

Bjorn Gustavsson
Bjorn Gustavsson el 21 de Ag. de 2020
Unfortunately you will have to do something like this:
[dudx,dudy,dudz] = gradient(u,squeeze(x(1,:,1)),squeeze(y(:,1,1)),squeeze(z(1,1,:)));
If you want the gradients of the wind-vector components in wind.mat.
Two additional points to mention about gradient:
1, it does not give a properly centred difference approximation to the gradient for cases where the coordinates are not varying linearly. It just uses a naive centred difference-scheme.
2, the above obviously requires the grid to be plaid.
HTH

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by