필터 지우기
필터 지우기

lsqr solving augmented linear equation

조회 수: 2 (최근 30일)
bolin pan
bolin pan 2016년 2월 18일
I would like to use lsqr to solve the augmented equations (A; alpha*I)*f = (g;0) for f, where A is an 256*256 matrix, I is 256*256 identity matrix and g is a 256*256 matrix. Since lsqr only allows the input to be column vectors, I would like to write a function afun to pass in. The code of my function afun is:
function z=afun(x,type,alpha)
.....A....(here I generated the matrix A)
a = [A;alpha*eye(256)];
b = a *x;
bb = a' *x;
if strcmp(type,'notransp')
z = b(:);
elseif strcmp(type,'tansp')
z = bb(:);
end
Then I plugged in my function afun to lsqr:
alpha = 0.1;
D = [g;zeros(size(g,1))];
lsqr(@(x,type)afun(x,type,alpha),D(:));
I got a warning that To RESHAPE the number of elements must not change. I think that is something wrong for my afun, especially the if..elseif..part, can someone help me to modify this error? Thanks so much.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Strategy & Logic에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by