%% Compute and Plot the Least Square Approximation of a Bivariate Function
% This example shows how to create a bivariate function, and compute and plot its least-square approximation.
% Generate the data for the approximation and the bivariate function.

x = -2:.2:2; 
y=-1:.25:1; 
[xx, yy] = ndgrid(x,y); 
z = exp(-(xx.^2+yy.^2)); 

% Compute the least-square approximation and plot it.

sp = spap2({augknt([-2:2],3),2},[3 4],{x,y},z);
fnplt(sp)

% Copyright 2020 The MathWorks, Inc.