天天看點

matlab 矩陣除法 0,Matlab中的矩陣除法有問題???

該樓層疑似違規已被系統折疊 隐藏此樓檢視此樓

x=rand(5)

x =

0.5470    0.1835    0.9294    0.3063    0.6443

0.2963    0.3685    0.7757    0.5085    0.3786

0.7447    0.6256    0.4868    0.5108    0.8116

0.1890    0.7802    0.4359    0.8176    0.5328

0.6868    0.0811    0.4468    0.7948    0.3507

>> a=rand(5)

a =

0.9390    0.2077    0.1948    0.3111    0.9797

0.8759    0.3012    0.2259    0.9234    0.4389

0.5502    0.4709    0.1707    0.4302    0.1111

0.6225    0.2305    0.2277    0.1848    0.2581

0.5870    0.8443    0.4357    0.9049    0.4087

>> y=x*a

y =

1.7546    1.2212    0.6571    1.3791    1.0621

1.5666    0.9747    0.5541    1.2027    0.8242

2.3095    1.3754    0.8394    1.8476    1.5218

1.9224    1.1179    0.7058    1.6000    1.0048

1.6624    0.8568    0.5621    0.9450    1.1066

>> x1=y*inv(a)

x1 =

0.5470    0.1835    0.9294    0.3063    0.6443

0.2963    0.3685    0.7757    0.5085    0.3786

0.7447    0.6256    0.4868    0.5108    0.8116

0.1890    0.7802    0.4359    0.8176    0.5328

0.6868    0.0811    0.4468    0.7948    0.3507

>> norm(x1-x)

ans =

3.1081e-015誤差很小了

x2=y/a (與x2=y*inv(a)等價)

x2 =

0.5470    0.1835    0.9294    0.3063    0.6443

0.2963    0.3685    0.7757    0.5085    0.3786

0.7447    0.6256    0.4868    0.5108    0.8116

0.1890    0.7802    0.4359    0.8176    0.5328

0.6868    0.0811    0.4468    0.7948    0.3507

>> norm(x2-x)

ans =

1.7692e-015誤差很小了