MATLAB Matlab interpolation for 3 axis data

Click For Summary
The discussion centers on using MATLAB for creating and interpolating 3D graphs in a medical project. The user has generated a graph using fixed vectors for X and Y, with corresponding measured values for Z. They seek guidance on how to interpolate the graph to achieve smoother lines. A practical example of MATLAB code is provided, which demonstrates how to increase the sampling of the data by a factor of four using the `interp2` function with 'spline' interpolation. The code includes steps for setting up the meshgrid, applying the `surf` function, and using `shading interp` to enhance the visual quality of the graph. This approach is specifically noted to work with square matrices.
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 totaly 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
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K