专题软件开发实践报告(4)

发布时间:2021-06-05

% --- Executes on button press in pushbutton5.

function pushbutton5_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton5 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) s1=str2double(get(handles.edit2,'String'))

s2=str2double(get(handles.edit3,'String'))

s3=str2double(get(handles.edit4,'String'))

% Set up grid.

h = 1/s1;

x = [h/2:h:1-h/2]';

% Compute matrix K corresponding to convolution with Gaussian kernel.

kernel = (1/sqrt(pi)/s2) * exp(-(x-h/2).^2/s2^2);

K = toeplitz(kernel)*h;

% Set up true solution f_true and data d = K*f_true + error.

f_true = .75*(.1<x&x<.25) + .25*(.3<x&x<.32) + (.5<x&x<1).*sin(2*pi*x).^4;

Kf = K*f_true;

eta = s3/100 * norm(Kf) * randn(s1,1)/sqrt(s1);

d = Kf + eta;

% Display the data.

% Compute an eigendecomposition of K. K is symmetric, so this is % equivalent to an SVD.

[V,svals] = eig(K);

[svals,indx] = sort(-diag(svals)); % Sort -eigenvalues in decreasing order.

svals = -svals; % +eigs are in increasing order. V = V(:,indx); % Corresponding eigenvectors.

%figure(3)

semilogy(svals,'o')

xlabel('index i')

ylabel('\sigma_i')

title('Singular Values of K')

axes(handles.axes1);

上一篇:家具设计概述

下一篇:期末补考项目卷

精彩图片

热门精选

大家正在看