matlab code for preconditioner P

1 次查看(过去 30 天)
Matlab code for preconditioner P Given a linear equation of the form Ax=b For example where A=[6 2 4;3 4 3; 3 1 2] and b=[26 19 13]' A =
6 2 4
3 4 3
3 1 2
b =
26
19
13
I need matlab code for a preconditional P such that
P=
1 -2/A(2,2) 0
0 1 -3/A(3,3)
0 0 1
P= 1 -0.5 0 0 1 -1.5 0 0 1
2. I need a matlab code to convert the main diagonal of a matrix to one for example A= 6 2 4 3 4 3 3 1 2 F== 1 2/6 4/6 3/4 1 3/4 3/2 1/2 1

回答(1 个)

Steven Lord
Steven Lord 2016-6-27
Replace "a22" in your expression for P with "A(2, 2)" [and similarly for a33] and add in some square brackets, maybe some semicolons and/or commas to make it explicit what matrix you're creating, and you should be all set.
For part 2, I'll just give you a hint: look at the diag function.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by