Say if I have three 1xn vectors representing n (X, Y, Z) value pairs, if I would like to generate a surface plot using these three vectors (with some smoothing), what would be the quickest way of doing it?
Depending on what you mean by smoothing, Curve Fitting Toolbox might be a good bet. This will allow you to do both interpolations, as well as smoothed fits to your data.
You can either use the interactive tool:
cftool
Or you can operate from the command line. In this section I've fitted a surface, used the fit object to make a prediction for z
with my first x
and y
values, and then plotted the fitted surface. For reference, the documentation for fit
can be found here: http://www.mathworks.co.uk/help/curvefit/fit.html
Example data:
load franke
Lowess Smoothing
f = fit([x,y],z, 'lowess')
zPrediction = f(x(1), y(1))
plot(f)
Piecewise Cubic Interpolant
f = fit([x,y],z, 'cubicinterp')
zPrediction = f(x(1), y(1))
plot(f)
User Defined Equation
f = fit([x,y],z, 'a*x+b*exp(y)+c')
zPrediction = f(x(1), y(1))
plot(f)