How to create 3D interpolated surface from separate lines in different arrays
1 view (last 30 days)
Show older comments
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
Answers (1)
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)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!