You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: fit_example.m
    path of file: ./repos/spinw/tutorials/tutorial
    
    the code of the file until where you have to start completion: %% Generate artificial data
% We use a single gaussian function with linear background and simulating
% Poisson statistics.

% parameters
Amp  = 70;
Cen  = 50;
Wid  = 20;
Bkg  = 20;

% ideal function values
xDat = 0:100;
pDat = [Amp Cen W
    
function at 95% confidence level.
[pFit,yCalc,fitRes3] = ndbase.lm(sig,@fitfun.ngaussbkg,[300 40 10 0 15],'confLev',0.95,'extraStat',true);

figure
subplot(2,2,1)
% Plot the gridded parameter search as a function of the first 2 parameter
% values.

Ngrid   = 51;
[p1,p2] = ndgrid(linspace(0,150,Ngrid),linspace(25,75,Ngrid));
Chi2    = zeros(Ngrid);

for ii = 1:Ngrid
    for jj = 1:Ngrid
        yTemp = fitfun.ngaussbkg(sig.x,[p1(ii,jj) p2(ii,jj) Wid 0 Bkg]);
        dy = sig.y - yTemp;
        Chi2(ii,jj) = dy*dy'/(numel(sig.x)-numel(pFit));
    end