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

2 Ansichten (letzte 30 Tage)
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);

Akzeptierte Antwort

KSSV
KSSV am 29 Mai 2020
Bearbeitet: KSSV am 29 Mai 2020
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") ;

Weitere Antworten (0)

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by