How to interpolate in 2d with the 3rd variable as a vector?
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have contour data and its x-y coordinates. I successfull plotted the data using griddata which shows contours around the points only. I want to interpolate the data in 2-dimension to have the plot spreaded over 160x60 grid. I tried using interp2(x,y,dt,x1,y1) but it gives error "Interpolation requires at least two sample points for each grid dimension." Is there a way the interpolation is carried out in 2-dimension and the contour shows up to the limits, or my data are insufficient for 2d interpolation?
I would appreciate help.
~Best
dt = [3.96 4.36 0.6 2.6 1.44 3.84 3.64 0.72];
x = [80 120 40 60 100 100 80 80];
y = [40 60 80 80 80 120 160 0];
[x1,y1] = meshgrid(0:20:160,0:20:160);
z1 = griddata(x,y,dt,x1,y1);
contourf(x1,y1,z1,'ShowText','on');
grid on
0 commentaires
Réponse acceptée
Simon Chan
le 3 Juin 2023
dt = [3.96 4.36 0.6 2.6 1.44 3.84 3.64 0.72];
x = [80 120 40 60 100 100 80 80];
y = [40 60 80 80 80 120 160 0];
[x1,y1] = meshgrid(0:20:160,0:20:160);
z1 = griddata(x,y,dt,x1,y1);
idxNaN = isnan(z1);
znew = fillmissing2(z1,'nearest','MissingLocations',idxNaN);
contourf(x1,y1,znew,'ShowText','on');
grid on
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!