Curl, Divergence calculation from velocity data

Hi,
I have calculate the Curl, Divergence from the velocity data file available in 4650 x 4 array. Here 1, 2, 3, and 4 columns reprsents x, y, u, v. I have tried with below script, but I am getting some error. Please help..
X = data (:,1);
Y = data (:,2);
UU = data (:,3);
VV = data (:,4);
[X,Y] = meshgrid(X,Y);
[UU, VV] = meshgrid(UU,VV);
f = curl(UU,VV);

2 件のコメント

Sudheer Bhimireddy
Sudheer Bhimireddy 2020 年 8 月 6 日
"some error" doesn't help much. Post your error so that we can help.
Turbulence Analysis
Turbulence Analysis 2020 年 8 月 7 日
Hi, The error msg is as below
Index in position 1 is invalid. Array indices must be positive integers or logical values.

サインインしてコメントする。

回答 (3 件)

Bruno Luong
Bruno Luong 2020 年 8 月 7 日
編集済み: Bruno Luong 2020 年 8 月 7 日

1 投票

Your data is already gridded, no need to gridded on top of it
load('matlab.mat')
UU=reshape(data(:,3),[75 62]);
VV=reshape(data(:,4),[75 62]);
X=reshape(data(:,1),[75 62]);
Y=reshape(data(:,2),[75 62]);
close all
figure
quiver(X,Y,UU,VV);
f = curl(UU,VV);
figure
imagesc(f');

1 件のコメント

Turbulence Analysis
Turbulence Analysis 2020 年 8 月 7 日
Hi, Bruno,
Many thanks for your quick reply..
Actually, I am getting only vector plot. Stiil, getting below error while exceuting 'curl'
Index in position 1 is invalid. Array indices must be positive integers or logical values.

サインインしてコメントする。

Turbulence Analysis
Turbulence Analysis 2020 年 8 月 7 日

0 投票

Hi, Bruno,
Now, I am able to execute curl function. However, it seems, some mistake in curl computtaion. Actually, the calculated vorticity should look something similar to the attached fig.
Furthermore, I would like to get the vector plot and vorticty plot on the same fig, I tried with 'hold on', but I am not gettting correct figure..
I would be great if you could help me with this...

5 件のコメント

Bruno Luong
Bruno Luong 2020 年 8 月 7 日
編集済み: Bruno Luong 2020 年 8 月 7 日
load('matlab.mat')
sz = [75 62];
UU=reshape(data(:,3),sz);
VV=reshape(data(:,4),sz);
X=reshape(data(:,1),sz);
Y=reshape(data(:,2),sz);
x=X(:,1);
y=Y(1,:);
f = curl(x,y,UU',VV');
close all
figure
imagesc(x,y,f);
hold on
V = sqrt(UU.^2+VV.^2);
quiver(X,Y,UU./V,VV./V,'k');
colormap(jet)
set(gca,'ydir','normal')
Turbulence Analysis
Turbulence Analysis 2020 年 8 月 7 日
Thanks a lot Bruno.
Furthermore, If I have to calculte divergence, for e.g. dVx/dy or dVx/dx.. Do i hve to just use 'divergence' ??
Bruno Luong
Bruno Luong 2020 年 8 月 7 日
yes
Turbulence Analysis
Turbulence Analysis 2020 年 8 月 7 日
Thnaks..
For instnace if I need to get only dVx/dy , how to implement this ..
Bruno Luong
Bruno Luong 2020 年 8 月 7 日
doc gradient

サインインしてコメントする。

Turbulence Analysis
Turbulence Analysis 2020 年 8 月 7 日

0 投票

Hi,
Many thanks for your support..
For gradieant I have used as follows
[dx, dy]= gradient (UU');
I am getting good results
I am getting good results...

カテゴリ

質問済み:

2020 年 8 月 6 日

回答済み:

2020 年 8 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by