Code Analyzer: INV is slow and inaccurate

前端 未结 3 1332
一向
一向 2021-01-23 09:16

When I try to calculate a matrix inverse using Matlab\'s inv() operation:

A = rand(10,10);
b = rand(10,1);

C = inv(A);
D = C*b;

I get the foll

3条回答
  •  无人共我
    2021-01-23 10:17

    If you absolutely need the inverse later on, then you have to compute it. If you can use the backslash operator (\) instead of an inverse again later on, I would stay away from the inverse and listen to MATLAB's suggestion. For numerical reasons, it is always better to use a slash operator when you can, so the second approach is better even though it is slower.

提交回复
热议问题