# How to use the gaussian process regression function in matlab 2015b ?

I’m trying to reproduce the picture at the end of the documentation:

<http://www.mathworks.com/help/stats/gaussian-process-regression-models.html> the one on the left.

However, I cant quite do it.

This is what I have so far:

`fun = @(x) x.*sin(x);xx = linspace(0,10,100)';yy = fun(xx);nd = 5;xd = linspace(1,9,nd)';yd = fun(xd);gp = fitrgp(xd,yd,'KernelFunction','squaredexponential');figure(1); clfplot(xx,yy, 'g-')hold onplot(xx,predict(gp,xx), 'r-')`

However this doesn’t work. It looks like the beta parameter is set at a constant and you can change the basis function used. But, why use Gaussian Processes if you have to provide it with the function you’re trying to emulate? I’m trying to use GPs to model simulation data and the process that generate them can’t be written as a nice function (basis function).

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

Here’s how you can reproduce the doc example:

`% True curve.      fun = @(x) x.*sin(x);      xx  = linspace(0,10,100)';      yy  = fun(xx);      % Example points (from doc). You can do xd = linspace(1,9,nd)' as well       % but you will get a different fit.          xd = [1,3,5,6,7,8]';      yd = fun(xd);      % Fit a GP model. Initialize 'Sigma' to a small value. A GP estimates      % its parameters by maximizing the marginal log likelihood. Depending      % on the data, the marginal log likelihood can have multiple local      % optima corresponding to different interpretations of the data.      % Initializing 'Sigma' to a small value discourages the high noise      % variance interpretation of the data.      gp = fitrgp(xd,yd,'KernelFunction','squaredexponential','sigma',0.1,'verbose',1);      % Plot.      figure(1); clf      plot(xx,yy, 'r-.')      hold on;`