clear all; close all; clc; rng(0,'twister'); % For reproducibility % Generate data with an exponential trend x = (0:0.5:5)'; y = 2*exp(-0.2*x) + 0.1*randn(size(x)); xpred = (0:0.02:5)'; gprMdl0 = fitrgp(x,y, 'KernelFunction','ardsquaredexponential','Sigma',1e-02,... 'FitMethod','exact','PredictMethod','exact'); ypred0 = predict(gprMdl0,xpred); figure plot(x,y,'b.'); hold on; plot(xpred,ypred0,'r','LineWidth',1.5); xlabel('x'); ylabel('y'); legend('Data','GPR predictions'); hold off gprMdl1 = fitrgp(x,y, 'KernelFunction','ardsquaredexponential','Sigma',0.5e-01,... 'FitMethod','exact','PredictMethod','exact'); ypred1 = predict(gprMdl1,xpred); figure plot(x,y,'b.'); hold on; plot(xpred,ypred1,'r','LineWidth',1.5); xlabel('x'); ylabel('y'); legend('Data','GPR predictions'); hold off gprMdl2 = fitrgp(x,y, 'KernelFunction','ardsquaredexponential',... 'FitMethod','exact','PredictMethod','exact'); ypred2 = predict(gprMdl2,xpred); figure plot(x,y,'b.'); hold on; plot(xpred,ypred2,'r','LineWidth',1.5); xlabel('x'); ylabel('y'); legend('Data','GPR predictions'); hold off