Invert Matrix Command

A and B are matrices, which A is invers from B. Is there any differences between A=B^-1; A=B.\1; A=inv(B);
coz i have different result from 3 command above

댓글 수: 12

Jan
Jan 2011년 11월 15일
What about trying it in Matlab and comparing the results?
andy ganteng
andy ganteng 2011년 11월 15일
Yes i have tried, but in my case when i used A=B^-1 and A=inv(B) i get Inf result. it was different with A=B.\1 , although explanation in matlab help showed simmiliarity between all those command, that was i guess....maybe im wrong.
Grzegorz Knor
Grzegorz Knor 2011년 11월 15일
As I mentioned, "A=B.\1" method is wrong. First, check the determinant of the matrix. If its determinant is 0, the matrix is singular
andy ganteng
andy ganteng 2011년 11월 15일
is there any method to avoid Inf result when create inverse matrix?
Jan
Jan 2011년 11월 15일
"Avoid"? Building the inverse is a well-defined mathematical operation. There are no degrees of freedom which allow to modify the result.
It is like a division by zero: You can catch this case, but you cannot avoid, that the result is Inf (or NaN for some cases).
andy ganteng
andy ganteng 2011년 11월 15일
what about pinv?is that another choice for me?
Grzegorz Knor
Grzegorz Knor 2011년 11월 15일
Can you write how you make the matrix B and why do you need the inverse matrix?
andy ganteng
andy ganteng 2011년 11월 15일
This is my data, i call it matrix y, which consist y1 and y2.
y1=y(:,1); and y2=y(:,2);
91.3600000000000 9.09000000000000
81.9800000000000 8.04000000000000
83.3900000000000 7.95000000000000
89.9300000000000 7.32000000000000
83.3800000000000 7.94000000000000
88.2100000000000 7.26000000000000
83.1100000000000 6.88000000000000
79.0700000000000 6.44000000000000
94.0500000000000 10.5400000000000
87.3666666666667 8.62756395875771
51.6500000000000 3.79187935524974
96.3123697889276 9.05000000000000
83.5201129290811 6.47628937657751
88.2822635556373 6.53120884650403
97.7485157937070 9.26010524849543
62.9108356860225 6.21188000000000
86.8054178430113 6.10960000000000
87.2876058710136 6.70809271547082
31.7541784301126 3.10103746017809
31.3541784301126 3.89263270542303
31.0704319591464 3.93979332207437
31.8054178430113 2.41932709948679
31.7571174473266 2.45365318072931
32.8654584109626 2.94404622817266
87.1108356860225 6.41229552674817
91.1162535290338 7.32147940127193
76.8792490107883 6.29018684796355
95.7053482338574 7.97101408843632
64.1054178430113 4.45535798833371
30.5254178430113 2.78703470631920
32.6825070580676 3.33189666711284
32.1254178430113 2.89685219459403
32.7709486151037 2.72341621277990
32.1054178430113 2.79210000000000
32.9850988129460 3.42999394839633
99.1000000000000 10.8835853352147
then a wanna make covariance matrix from y1 and y2. After that i need the inverse from that covariance matrix.
andy ganteng
andy ganteng 2011년 11월 15일
I used this command
y1=y(:,1);
y2=y(:,2);
nn=length(y1);
vary1=((y1-mean(y1))*(y1-mean(y1))')/(nn);
vary2=((y2-mean(y2))*(y2-mean(y2))')/(nn);
covy12=((y1-mean(y1))*(y2-mean(y2))')/(nn);
covy21=((y2-mean(y2))*(y1-mean(y1))')/(nn);
w=[vary1 covy12;covy21 vary2];
W=inv(w);
the result always Inf.
andy ganteng
andy ganteng 2011년 11월 15일
I used W for the weight matrix in weighted least square regression for biresponse regression. please help.
Grzegorz Knor
Grzegorz Knor 2011년 11월 16일
Each row in a matrix w is linearly dependent, so rank(w) = 1.
hold all
for k=2:72
plot(w(1,:)./w(k,:))
end
There is no an inverse matrix in this case.
andy ganteng
andy ganteng 2011년 11월 21일
thanks

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

 채택된 답변

Grzegorz Knor
Grzegorz Knor 2011년 11월 15일

0 개 추천

Statement A=B.\1 doesn't calculate an inverse matrix. You probably mean:
A2=B\eye(size(B))
B^-1 and inv(B) give the same result. B\eye(size(B)) is a little different, because it uses different algorithm.

추가 답변 (0개)

카테고리

도움말 센터File 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