필터 지우기
필터 지우기

Plot xyz point data to 3D contour

조회 수: 3 (최근 30일)
Amra Rajuli
Amra Rajuli 2021년 3월 28일
댓글: Star Strider 2021년 4월 12일
How to plot the xyz point data (attached) into 3D contour? Thank you
  댓글 수: 1
Amra Rajuli
Amra Rajuli 2021년 3월 28일
the xy data is not evenly space or irregular

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

채택된 답변

Star Strider
Star Strider 2021년 3월 28일
Try this:
D = readmatrix('data.txt');
x = D(~(any(isnan(D),2)),1);
y = D(~(any(isnan(D),2)),2);
z = D(~(any(isnan(D),2)),3);
N = 50;
xv = linspace(min(x), max(x), N);
yv = linspace(min(y), max(y), N);
[X,Y] = ndgrid(xv, yv);
Z = griddata(x, y, z, X, Y);
figure
surf(X, Y, Z)
.
  댓글 수: 4
Amra Rajuli
Amra Rajuli 2021년 4월 12일
what if the input is shape file. your code would be:
D = shaperead('Cross_9_Agustus_2020_A1.shp')
x = D.X(~(any(isnan(D),2)),4);!starting error
y = D.Y(~(any(isnan(D),2)),5);
z = D.Z(~(any(isnan(D),2)),6);
N = 100;
xv = linspace(min(x), max(x), N);
yv = linspace(min(y), max(y), N);
[X,Y] = ndgrid(xv, yv);
Z = griddata(x, y, z, X, Y);
figure
contour(X, Y, Z,10);
however, it was written in error part that:
Undefined function 'isnan' for input arguments of type 'struct'.
do you familiar with that problem? Thank you in advance
Star Strider
Star Strider 2021년 4월 12일
The shaperead function requires the Mapping Toolbox, that I do not have.
I cannot run your code.
However, removing the NaN values from the structure would likely be straightforward:
Dnonan = structfun(@(x)x(~(any(isnan(x),2))),D, 'Unif',0);
x = Dnonan.X;
y = Dnonan.Y;
z = Dnonan.Z;
See if that does what you want. (It worked with a random structure I created to test this, with the fields of ‘D’ being column vectors.)
Make appropriate changes to get thee result you want.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by