pikachu
pikachu

Reputation: 612

Matlab 3D interpolation

I have 3 matrices(129x129) corresponding to x, y and z coordinates. I used the function mesh

mesh(x,y,z);

to plot the corresponding figure. It comes out to be a sphere. Now, I have another set of x, y, z(again 129) which gives a different sphere. What I want is to use interpolation in MATLAB to obtain the figures that come in between. I looked at the function interp3 in MATLAB but could not figure out what to do with it.

Upvotes: 2

Views: 331

Answers (1)

Shai
Shai

Reputation: 114786

It seems like you are interested in the evolution of the surface z(x,y) from one surface z0 to another z1. I would suggest the following process

 T = 5; % number of "time steps" from z0 to z1
 t = linspace( 0, 1, T );
 for ii = 1 : T
     zt = t(ii).*z1 + (1-t(ii)).*z0;
     mesh( x, y, zt ); title( sprintf( 'time %d', ii ) );
     drawnow;
     pause(1); wait a sec
 end

Upvotes: 4

Related Questions