Azzera filtri
Azzera filtri

How to calculate the gradient of 3D velocity

28 visualizzazioni (ultimi 30 giorni)
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 Commento
KSSV
KSSV il 21 Ago 2020
Read the documentation properly......if you provide an array, you will get all the components at once.

Accedi per commentare.

Risposta accettata

Bjorn Gustavsson
Bjorn Gustavsson il 21 Ago 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

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by