Countour plot based on velocity data

조회 수: 2 (최근 30일)
JACK LONDON
JACK LONDON 2022년 12월 24일
편집: JACK LONDON 2022년 12월 25일
I have data consist of X(x coordinate) Y(y coordinate) Z(velocity). I created below countour plot with especial flow software as below:
I try to plot countour in matlab with below code but it gives wrong results.
xyz=dlmread('velocity.txt');
x=xyz(:,1);
y=xyz(:,2);
z=xyz(:,3);
[X,Y]=meshgrid(min(x):max(x),min(y):max(y));
Z=griddata(x,y,z,X,Y);
contourf(X,Y,Z)
Which code I need to create velocity countour similar to first image? Thank you.
Note: I uploaded my data as an attachment.

채택된 답변

Voss
Voss 2022년 12월 24일
The x and y don't quite make a grid (a point is missing in the upper-left corner near (0,2)):
xyz = readmatrix('velocity.txt');
plot(xyz(:,1),xyz(:,2),'.')
so it's most convenient to use a scatteredInterpolant:
I = scatteredInterpolant(xyz(:,1),xyz(:,2),xyz(:,3));
[x,y] = meshgrid(unique(xyz(:,1)),unique(xyz(:,2)));
contourf(x,y,I(x,y))
colorbar

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by