필터 지우기
필터 지우기

How to calculate the gradient of 3D velocity

조회 수: 28 (최근 30일)
Xinchen Zhang
Xinchen Zhang 2020년 8월 21일
답변: Bjorn Gustavsson 2020년 8월 21일
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
KSSV
KSSV 2020년 8월 21일
Read the documentation properly......if you provide an array, you will get all the components at once.

댓글을 달려면 로그인하십시오.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2020년 8월 21일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by