MATLAB: Gridfit is undifined for Matlab 2017b

gridfit

Hi,
I am trying to run the following code to have uniform input using Matlab R2017b, however, I have received this error 'Undefined function or variable 'grid fit'. I would like to know how I should solve this problem.
Ymin=min(Y); %find minimum Y value
Ymax=max(Y); %find maximum Y value
Ynum=fix((Ymax-Ymin+1)/5); %set number of Y points to use for grid
Hmin=min(H); %find minimum H value
Hmax=max(H); %find maximum H value
Hnum=fix((Hmax-Hmin+1)/5); %set number of H points to use for grid
Ynodes=linspace(Ymin,Ymax,Ynum); %set nodes for the Y direction
Hnodes=linspace(Hmin,Hmax,Hnum); %set nodes for the H direction
[Ygrid,Hgrid]=meshgrid(Ynodes,Hnodes); %create the Y and H grids
[Y,H,z,Ynodes,Hnodes] = gridfit(Y,H,z,Ynodes,Hnodes);
zgrid = [Y,H,z,Ynodes,Hnodes]; %create the zgrid (z for each Y,H)
zgridmin=0; %set the minimum elevation desired
zgridmax=3; %set the maximum elevation desired
[zgridY,zgridH]=size(zgrid); %get the size of the grid
YG = zgridY;
HG = zgridH;
%go through the grid and adjust any points out of desired range
for i=1:YG
for j=1:HG
if zgrid(i,j)<zgridmin
zgrid(i,j)=zgridmin;
end
if zgrid(i,j)>zgridmax
zgrid(i,j)=zgridmax;
end
end
end
L=zgridmax-zgridmin-1;
%create plot with lines at integer values by picking proper number to plot
[C,hh]= contour(Ygrid,Hgrid,zgrid,L);
set(hh,'ShowText','on','TextStep',get(hh,'LevelStep'))

Best Answer

gridfit is not a Mathworks function. It is available in the file exchange.
https://www.mathworks.com/matlabcentral/fileexchange/8998-surface-fitting-using-gridfit