Interp2/Scatterinterp unstructured Data don't work!

1 vue (au cours des 30 derniers jours)
Meddour Aissam riad
Meddour Aissam riad le 20 Jan 2021
Commenté : Star Strider le 20 Jan 2021
Hi MathworKS community,
i hava a set of data that i can plot like the picture below , as you see it dosen't cover all the area
so when i use interp2 to find the value of Z inside the contour i get this error 'Input grid is not a valid MESHGRID.'
i have an idea : fill the empty area with Nan, but it's a little bit confusig for me.
any solution?
contourf(X,Y,Z)
colormap jet;
interp2(X,Y,Z,3000,50) %for example i want to interpolate at X=3000 and Y=50

Réponse acceptée

Star Strider
Star Strider le 20 Jan 2021
Use the griddata function instead.
Try this:
Xm = load('X.mat');
X = Xm.Mecanical_Speed;
Ym = load('Y.mat');
Y = Ym.Torque_max_Matrice;
Zm = load('Z.mat');
Z = Zm.Efficiency;
Xi = 3000;
Yi = 50;
Zi = griddata(X,Y,Z,Xi,Yi) %for example i want to interpolate at X=3000 and Y=50
figure
contourf(X,Y,Z)
hold on
plot3(Xi, Yi, Zi, '+k', 'MarkerSize',20)
hold off
colormap jet;
text(Xi,Yi,Zi, sprintf(' \\leftarrow (%3d, %2d, %.3f)', Xi,Yi,Zi), 'VerticalAlignment','middle','HorizontalAlignment','left', 'FontWeight','bold')
producing:
.
  2 commentaires
Meddour Aissam riad
Meddour Aissam riad le 20 Jan 2021
Thanks a lot MVP! @Star Strider
Star Strider
Star Strider le 20 Jan 2021
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Contour Plots 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!

Translated by