How to create 3D interpolated surface from separate lines in different arrays

1 view (last 30 days)
Hello Everyone,
I a few transects of a construction survey site that I need to turn into a surface to create a visual represenation of the landscape. I have a series of arrays in from different tables that I would like to interpolate into a single smoothed surface using a cubic fit. I have tried a few different things, but I have not quite gotten the surface to work. Below is a picture of the individual lines I would like to create into an interpolated surface, with additional code that did not work. Since the lines are from individual tables I cannot concatanate them due to having seperate cooridnates associated with the each line. I have already tried concatatnate prior, it created addition error lines between the real lines that caused some issues. If possible, is there a way to create a smoothed surface between the lines
code does not work:
lon = [CL_2017.LON;NL_2017.LON;SL_2017.LON;SC_2017.LON;MC_2017.LON;NC_2017.LON]
lon_s = linspace(min(lon), max(lon), 100);
lat= [CL_2017.LAT;NL_2017.LAT;SL_2017.LAT;SC_2017.LAT;MC_2017.LAT;NC_2017.LAT]
lat_s = linspace(min(lat), max(lat), 100);
zval = [ice_surf;ice_surf_1;ice_surf_2;ice_surf_3;ice_surf_4;ice_surf_5]
[x,y,z] = meshgrid(lat,lon, zval);
% vq = interp3(lat, lon, zval, x, y, z, 'cubic', -1);
figure
surface(x, y , z);
  2 Comments
Cody Barnett
Cody Barnett on 7 Aug 2019
Hi Bruno, unfortunately I cannot post since it is not my own (I work at a university and we have some stringent policies about data sharing), also it is in 6 seperate csv files. Thank you for asking though!

Sign in to comment.

Answers (1)

KSSV
KSSV on 7 Aug 2019
Join all the points you have into a matrix of size n*3..i.e in the form (x,y,z). Not you have scattered data in hand. Do interpolation.
F = scatteredInterpolant(x,y,z) ;
m = 100 ; n = 100;
[X,Y] = meshgrid(linspace(min(x),max(x),m),linspace(min(y),max(y),n)) ;
Z = F(X,Y) ;
surf(X,Y,Z)
  1 Comment
Cody Barnett
Cody Barnett on 7 Aug 2019
Hi KSSV,
Thank you for the code, unfortunately, I am getting this error when attempting to run suggested. :( The concatanated arrays are very large as you can see, and I definitely do not have 75k gb memory or ram to allocate.
Error using repmat
Requested 21586x21586x21586 (74938.8GB) array exceeds maximum array size preference. Creation of arrays greater than this limit
may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.
Error in meshgrid (line 77)
xx = repmat(xx, ny, 1, nz);
Error in Surface_and_Base_Plotter_Niohalvfjerdsfjorden_1 (line 251)
[x,y,z] = meshgrid(lat,lon, zval);

Sign in to comment.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!