I have matrix A, calculate null(A) but then A*null(A) doesn't give me 0?

조회 수: 5 (최근 30일)
Haraldur Blöndal Kristjánsson
Haraldur Blöndal Kristjánsson 2020년 10월 21일
답변: Steven Lord 2020년 10월 21일
%a) The traffic flow is an overdetermined system 12 variables to 9 equations
A = [-1 0 0 0 0 0 0 1 0 0 0 0;
1 1 0 0 0 0 0 0 0 0 -1 0;
0 -1 1 0 0 0 0 0 0 0 0 0;
0 0 -1 -1 0 0 0 0 0 0 0 1;
0 0 0 1 1 0 0 0 0 0 0 0 ;
0 0 0 0 1 1 0 0 -1 0 0 0;
0 0 0 0 0 -1 1 0 0 0 0 0;
0 0 0 0 0 0 -1 -1 0 1 0 0;
0 0 0 0 0 0 0 0 1 -1 1 -1];
b = [0; 150; 20; -410; 180; 210; 80; -230; 0];
%b)Gives five free variables, so there is not a unique solution,
%meaning the traffic flow depends in other intersects
x = linsolve(A,b);
%e)
nullspace = null(A) %Three vectors in the nullspace
nullVector = A* nullspace(:,1) %Shouldn't this give me zero vector?
I am wondering if I calculate null(A) and tree null vectors:
0.0939 0.3560 -0.3875
-0.1103 0.2839 0.4184
-0.1103 0.2839 0.4184
-0.0000 0.0000 0.0000
0.0000 -0.0000 -0.0000
0.4610 -0.0825 0.2202
0.4610 -0.0825 0.2202
0.0939 0.3560 -0.3875
0.4610 -0.0825 0.2202
0.5549 0.2734 -0.1674
-0.0164 0.6399 0.0309
-0.1103 0.2839 0.4184
Shouldn't that mean A*nullspaceVector = 0 ?
But nullVector = A* nullspace(:,1) gives me:
nullVector =
1.0e-15 *
0.0139
-0.1180
0.3053
-0.3053
-0.0714
0.2776
-0.1665
0.2220
0.0971
  댓글 수: 1
Bruno Luong
Bruno Luong 2020년 10월 21일
편집: Bruno Luong 2020년 10월 21일
1.0e-15 * somenumber is considered as 0 numerically in floating point calculation.
Illustration of the same thing with simpler example
>> x=[3 4];
>> y=null(x)
y =
-0.8000
0.6000
>> x*y
ans =
-4.4409e-16

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2020년 10월 21일
Note that the description of the output argument on the documentation page for the null function does not include the character 0. It says that Z satisfies two properties, the key one of which for this question is "A*Z has negligible elements."
I would call 1e-15 or 1e-16 negligible relative to the elements in your matrix.

카테고리

Help CenterFile Exchange에서 Analysis of Variance and Covariance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by