% Variation on MATLAB code written by Curt Vogel, Dept of Mathematical Sciences, % Montana State University, for Chapter 1 of the SIAM Textbook, % "Computational Methods for Inverse Problems". % % Set up a discretization of a convolution integral operator K with a % Gaussian kernel. Generate a true solution and convolve it with the % kernel. Then add random error to the resulting data. % Set up parameters. clear; n = 100; %nunber of grid points ; sig = .05; % kernel width sigma err_lev = 10; %inputPercent error in data % Set up grid. h = 1/n; x = [h/2:h:1-h/2]'; %Compute matrix K corresponding to convolution with Gaussian kernel. C=1/sqrt(pi)/sig for i = 1:n for j = 1:n K(i,j) = h*C* exp(-((i-j)*h)^2/(sig^2)); end end % Set up true solution f_true and data d = K*f_true + error. f_true = .75*(.1