フィルターのクリア

lsqr solving augmented linear equation

1 回表示 (過去 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 Center および File ExchangeStrategy & Logic についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by