Solving linear system - but using only parts of the Matrix
1 view (last 30 days)
Show older comments
Hi everyone,
I'm trying to solve a linear system of equations but want to use only selectet rows for that operation.
For example:
D=
0 0 0 0 0.345265357599750 0.457309520629080 0.548726230994530 0 0 0 0
0 0 0 0 0.200398189744228 0.345265357599750 0.457309520629080 0 0 0 0
0 0 0 0 -0.00530900651840216 0.200398189744228 0.345265357599750 0 0 0 0
0 0 0 0 -0.369187964058863 -0.00530900651840216 0.200398189744228 0 0 0 0
0 0 0 0 -1.19314718055995 -0.369187964058863 -0.00530900651840216 0 0 0 0
0 0 0 0 -0.369187964058863 -1.19314718055995 -0.369187964058863 0 0 0 0
0 0 0 0 -0.00530900651840216 -0.369187964058863 -1.19314718055995 0 0 0 0
0 0 0 0 0.200398189744228 -0.00530900651840216 -0.369187964058863 0 0 0 0
0 0 0 0 0.345265357599750 0.200398189744228 -0.00530900651840216 0 0 0 0
0 0 0 0 0.457309520629080 0.345265357599750 0.200398189744228 0 0 0 0
0 0 0 0 0.548726230994530 0.457309520629080 0.345265357599750 0 0 0 0
U=
0
0
0
0
1.14881496080949e-07
3.47991801628408e-07
1.14881496080949e-07
0
0
0
0
I want to perform the operation
P=D\U
But only with the 3 rows that contain a result in the variable U.
P should be
P=
0
0
0
0
-7.42753614188724e-09
-2.87062227792614e-07
-7.42753614188723e-09
0
0
0
0
Can somebody help me, how to program this?
Very best
Christian
0 Comments
Accepted Answer
Star Strider
on 3 May 2021
D = [...
0 0 0 0 0.345265357599750 0.457309520629080 0.548726230994530 0 0 0 0
0 0 0 0 0.200398189744228 0.345265357599750 0.457309520629080 0 0 0 0
0 0 0 0 -0.00530900651840216 0.200398189744228 0.345265357599750 0 0 0 0
0 0 0 0 -0.369187964058863 -0.00530900651840216 0.200398189744228 0 0 0 0
0 0 0 0 -1.19314718055995 -0.369187964058863 -0.00530900651840216 0 0 0 0
0 0 0 0 -0.369187964058863 -1.19314718055995 -0.369187964058863 0 0 0 0
0 0 0 0 -0.00530900651840216 -0.369187964058863 -1.19314718055995 0 0 0 0
0 0 0 0 0.200398189744228 -0.00530900651840216 -0.369187964058863 0 0 0 0
0 0 0 0 0.345265357599750 0.200398189744228 -0.00530900651840216 0 0 0 0
0 0 0 0 0.457309520629080 0.345265357599750 0.200398189744228 0 0 0 0
0 0 0 0 0.548726230994530 0.457309520629080 0.345265357599750 0 0 0 0];
U = [...
0
0
0
0
1.14881496080949e-07
3.47991801628408e-07
1.14881496080949e-07
0
0
0
0];
ix = U~=0;
format long g
P = lsqr(D(ix,:),U(ix))
format short
.
2 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!