Borrar filtros
Borrar filtros

Retrieve data from arbitrary point from contourf plot

2 visualizaciones (últimos 30 días)
Mechrod
Mechrod el 10 de Abr. de 2019
Comentada: Mechrod el 10 de Abr. de 2019
Hi.
I'm plotting a x,y,T using 2D plot. Using the code below
[Xr,Yr,Tr] = griddata(x,y,T,unique(x),unique(y)','v4'); % http://www.alecjacobson.com/weblog/?p=1532
figure();
colormap(jet);
[cc,hh]=contourf(Xr,Yr,Tr,'Showtext','on','LevelList',[400 600 700 800 900 1000 1100 1200 1300]);
hold on
colorbar;
triplot(dt,'LineWidth',0.01,'color','k');
axis([0 0.006 0 0.003]);
i get this plot. But when i try to retrieve the T data from the plot, it always snaps to the nearest point of the grid data tha generated the plot.
deletar.PNG
Is there a way to retrive (programmatically) the T value from an arbitrary (x,y) position? Something like i have when using Tecplot (below), where i click the plot and it retrieves the interpolated values used the generate the image. My objective is to enter a x,y value and retrive the T value from that point.
del2.PNG
  1 comentario
Mechrod
Mechrod el 10 de Abr. de 2019
I found a way that meets my requirements, after carefully reading the meshgrid and griddata help. I hope it can help someone else.
First i set up 2 vectors containing x and y positions of my points of interest, xp and yp. Then use griddata to generate interpolated values (Tp) for those positions. (Thats all i needed!)
x = pos_nos(:,1); % original data
y = pos_nos(:,2);
T = pos_nos(:,3);
%
xp = [0.0001 ; 0.0008 ; 0.0014];
yp = [0.0001 ; 0.0008 ; 0.0014];
%
Tp = griddata(x,y,T,xp,yp,'natural');
After that, i can use meshgrid to generate a fine mesh where the results will be interpolated, in case i need to extract more data. Then i just use griddata and plot the image.
[xg,yg] = meshgrid(0:0.0001:0.006, 0:0.0001:0.004);
[Xr,Yr,Tr] = griddata(x,y,T,xg,yg,'natural');
figure();
colormap(jet);
[cc,hh]=contourf(Xr,Yr,Tr,'Showtext','on','LevelList',[400 600 700 800 900 1000 1100 1200 1300]);

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by