Using griddata with two points
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Christian Mathiesen
el 29 de Oct. de 2021
Respondida: Rishabh Singh
el 5 de Nov. de 2021
I have three datasets, containing x, y and z data. The datasets contains two, seven and fourteen points respectively. My goal is to visualize the increasing interpolation quality with increasing points. I have used griddata, but I am unable to create an interpolation with the dataset only containing two points. I get the error "Warning: The underlying triangulation is empty - the points may be collinear". I have searched around for a solution, and as far as I understand, griddata is unable to work with only two points. It is working fine with the other two datasets. Is there an alternative?
Thank you in advance!
TwoPoints = load('002536_2_punkter.txt');
SevenPoints = load('002536_7_punkter.txt');
FourteenPoints = load('002536_14_punkter.txt');
two_x = TwoPoints(:,1);
two_y = TwoPoints(:,2);
two_d = TwoPoints(:,3);
seven_x = SevenPoints(:,1);
seven_y = SevenPoints(:,2);
seven_d = SevenPoints(:,3);
fourteen_x = FourteenPoints(:,1);
fourteen_y = FourteenPoints(:,2);
fourteen_d = FourteenPoints(:,3);
v = 2000; %p-wave velocity of sediment
%Converting d-values from seconds to meter.
two_d = two_d .* v;
seven_d = seven_d .* v;
fourteen_d = fourteen_d .* v;
dx = 5;
x_ax=min(fourteen_x):dx:max(fourteen_x);
y_ax=min(fourteen_y):dx:max(fourteen_y);
[xx,yy]=meshgrid(x_ax,y_ax);
%Creating figures
figure();
Z_two = griddata(two_x,two_y,two_d,xx,yy,'cubic'); %This does not work
imagesc(x_ax,y_ax,Z_two)
hold on
plot(two_x,two_y,'k.','MarkerSize',22);
scatter(two_x,two_y,8,two_d,'filled');axis image
hold off
colorbar
caxis([20 35])
set(gca,'YDir','normal')
figure();
Z_seven = griddata(seven_x,seven_y,seven_d,xx,yy,'cubic');
imagesc(x_ax,y_ax,Z_seven)
hold on
plot(seven_x,seven_y,'k.','MarkerSize',22);
scatter(seven_x,seven_y,8,seven_d,'filled');axis image
hold off
colorbar
caxis([25 50])
set(gca,'YDir','normal')
figure();
Z_fourteen = griddata(fourteen_x,fourteen_y,fourteen_d,xx,yy,'cubic');
imagesc(x_ax,y_ax,Z_fourteen)
hold on
plot(fourteen_x,fourteen_y,'k.','MarkerSize',22);
scatter(fourteen_x,fourteen_y,8,fourteen_d,'filled');axis image
hold off
colorbar
caxis([25 50])
set(gca,'YDir','normal')
2 comentarios
Rishabh Singh
el 1 de Nov. de 2021
It is not possible to create a mesh/surface from two points, you atleast need 3 points to triagulate a surface. So "griddata" will not be suitable for you. Can you explain the meaning " visualize the increasing interpolation quality ", so any alternate solution can be suggested.
Respuesta aceptada
Rishabh Singh
el 5 de Nov. de 2021
As you wish to compare the results of interpolation I would suggest you to start from atleat 3 data points, if that is possible. As two data points do not carry much information so as to perform interpolation of any sort.
Hope it helps.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!