Filter löschen
Filter löschen

lsqr solving augmented linear equation

2 Ansichten (letzte 30 Tage)
bolin pan
bolin pan am 18 Feb. 2016
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.

Antworten (0)

Kategorien

Mehr zu Strategy & Logic finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by