% % Example 15_4.m % clear all q = 0:.01:1; a = 0.05; b = 0.05; % % Compute surrogate and high-fidelity model responses on the interval [0,1] and at the % M=3 interpolation points q_interp and M=6 regression points q_regress % q_interp = [0 0.5 1]; q_regress = [0.1090 0.3404 0.4984 0.5853 0.7171 0.9407]'; X = [ones(6,1) q_regress q_regress.^2]; ys = (q-1/4).^2 + 1/2; ys_interp = (q_interp-1/4).^2 + 1/2; y = ys + a*(q+b).*sin(20*pi*q); y_regress = (q_regress - 1/4*ones(size(q_regress))).^2 + 1/2*ones(size(q_regress)) + a*(q_regress+b).*sin(20*pi*q_regress); w = X\y_regress; ys_regress = w(1)*ones(size(q)) + w(2)*q + w(3)*q.^2; % % Plot the solutions with M=3 interpolation points and M=6 regression points % figure(1) plot(q,y,'-b',q,ys,'--k','linewidth',3) hold on plot(q_interp,ys_interp,'ro','linewidth',8) hold off set(gca,'Fontsize',[22]); xlabel('Parameter q') ylabel('Model Response') legend(' High-Fidelity Response f(q)',' Surrogate f_S(q)','Training Data','Location','Northwest') %print -depsc chpt12_fig1a figure(2) plot(q,y,'-b',q,ys_regress,'--k','linewidth',3) hold on plot(q_regress,y_regress,'ro','linewidth',8) hold off set(gca,'Fontsize',[22]); xlabel('Parameter q') ylabel('Model Response') legend(' High-Fidelity Response f(q)',' Surrogate f_S(q)','Training Data','Location','Northwest') %print -depsc chpt12_fig1b