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 Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by