Search code examples
matlabinterpolationmatlab-figure

Is there a way in matlab to plot several 1D courves on specific coordinates over a 3D mesh?


For example, I got 3 pairs of 1-D loglog curves and additionally their associated cartesian coordinate points (x,y,z) of one of their ends A, B and C over a mesh surface S (z is positive downwards and linear but coincides in direction with the log(y)-axis from the curves). Is it possible to respresent in a single figure such system of plots in matlab? Moreover, obtain an interpolated slice from A,B and C?

The images from the question of user3281667 gives an insight of what we are trying to do here: https://gis.stackexchange.com/questions/252939/interpolating-xyz-data-in-arcgis-3d-analyst

Thanks.


Solution

  • Kind of solved. First we need to know in which format is our data, this case scattered. I concatenated a nx4 matrix with the preprocessed data A=[X Y Z C]. Then use the right tools, to plot use scatter3: scatter3(A(:,1), A(:,2), A(:,3),30, A(:,4), 'filled' ) enter image description here Now to interpolate, fisrt generate a grid refinement with meshgrid: [Xm, Ym, Zm] = meshgrid(min(X):2:max(X), min(Y):2:max(Y), min(Z):2:max(Z)) next interpolate using griddata Cm = griddata(X,Y,Z,C,Xm,Ym,Zm);and last plot again.

    figure
    scatter3(Xm(:), Ym(:), Zm(:), 30, Cm(:), 'filled' )
    

    enter image description here

    Thanks to user7431005