MATLAB: Plotting a surface or mesh

meshsurface

hi guys, im new and need matlab for illustrating certain things, easy question therefore
how do i plot these vectors in a three dimensional surface?
x1 = 2,4,6
x2 = 2,4,4,
x3 = 0.1,0.3,0.5
i can do this, but its not working propery, its just giving me points, no surface:
ti = 0:.1:1;
[XI,YI] = meshgrid(ti,ti);
ZI = griddata(x,y,z,XI,YI);
mesh(XI,YI,ZI), hold;
plot3(x,y,z,'o'), hold off
thank you very much, because this is not working : F = TriScatteredInterp(x,y,z);

Best Answer

This sort of works (it runs and produces an interpolated surface):
x1 = [2,4,6];
x2 = [2,4,4];
x3 = [0.1,0.3,0.5];
x = x1; y = x2; z = x3; % Assumption
xi = [2:0.1:6];
yi = [2:0.1:4];
[XI,YI] = meshgrid(xi,yi); % Interpolation Grid Must Match Data Range
ZI = griddata(x,y,z,XI,YI);
mesh(XI,YI,ZI), hold;
plot3(x,y,z,'o'), hold off
The griddata function does not allow extrapolation (extrapolation is not mentioned in the documentation), so asking it to do so produces a matrix of NaN values, and NaN values do not plot. This was the reason you were not getting any surface plotted. The scatteredInterpolant class allows extrapolation, so consider using it if you want to extrapolate.