How to extract the the right X,Y,Z value for obtaining the best contour plot similar than the complete contour

조회 수: 1 (최근 30일)
If I have a matrix A that contains 1041 rows with 3 columns (X, Y, Z)
How to extract exaclty 424 row-values from A that fits the best contour plot similar than the contour with all the rows values?
find attached A matrix [1041,4]. I would like to obtain the B matrix [424,4] still represent the best way the contour plot of:
x = A(:,1);
y = A(:,2);
z = A(:,3);

채택된 답변

KSSV
KSSV 2020년 5월 29일
편집: KSSV 2020년 5월 29일
Option 1:
load("A.mat") ;
x = A(:,1);
y = A(:,2);
z = A(:,3);
m = 21 ; n = 21 ; % can be changed
xi = linspace(min(x),max(x),m) ;
yi = linspace(min(y),max(y),n) ;
[X,Y] = meshgrid(xi,yi) ;
Z = griddata(x,y,z,X,Y) ;
idx = ~isnan(Z) ;
iwant = [X(idx) Y(idx) Z(idx)] ;
Option 2:
load("A.mat") ;
x = A(:,1);
y = A(:,2);
z = A(:,3);
[c,ia,ib] = unique(y) ;
N = length(c) ;
iwant = cell(N,1) ;
for i = 1:N
xi = x(ib==i) ;
yi = y(ib==i) ;
zi = z(ib==i) ;
%
n = round(length(xi)/2) ; % This you can chnage if you want
xxi = linspace(min(xi),max(xi),n)' ;
yyi = c(i)*ones(n,1) ;
zzi = interp1(xi,zi,xxi) ;
iwant{i} = [xxi yyi zzi] ;
end
iwant = cell2mat(iwant) ;
subplot(121)
scatter(x,y,50,z,'filled')
colorbar
title("Original")
subplot(122)
scatter(iwant(:,1),iwant(:,2),50,iwant(:,3),'filled')
colorbar
title("downsampled to best") ;

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by