Matlab interpolation for 3 axis data

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 6K views
Menton85
Messages
1
Reaction score
0
Hi,
I'm doing a project in medicine, I've used MATLAB to create 3d graphs using a vector with 5 fixed values as X, a vector with 7 fixed values as Y. As Z I have 5*7 measured values.

I need to interpolate my graph to "smoothen" the lines in the graph, but I am totally lost, I have no idea how to do this. Could someone show me a practical example of needed MATLAB code for this I would be very thankful.
 
Physics news on Phys.org
This might get you started, it interpolates and smooths the data by 4X. It only works on a square matrices at the moment.

clear all; close all;
mat = rand(7);
[X,Y] = meshgrid(1:7,1:7);
[XI,YI] = meshgrid(1:.25:7); %This increases sampling by 4X)
colormap(hsv)
surf(mat)
shading interp
Zsmooth = interp2(X,Y,mat,XI,YI, 'spline');
figure2 = figure;
figure2 = surf(XI,YI,Zsmooth);
shading interp