Using griddata with two points
10 views (last 30 days)
Christian Mathiesen on 29 Oct 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;
Z_two = griddata(two_x,two_y,two_d,xx,yy,'cubic'); %This does not work
Z_seven = griddata(seven_x,seven_y,seven_d,xx,yy,'cubic');
Z_fourteen = griddata(fourteen_x,fourteen_y,fourteen_d,xx,yy,'cubic');
Rishabh Singh on 5 Nov 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.