i am getting this errror in the following code alfa = inv([r00 r11 r10 r12; r11 r00 r01 r01;r10 r01 r00 r02; r12 r01 r02 r00])*[r01 r10 r11 r11];
MATLAB: INV(A)*b can be slower and lass accurate than A/b./ consider using A/b for INV(A)*b or b/A for b*INV(A). how to get rid of this warning
inv function
Related Solutions
In the case where you know that M is the square identity matrix with the same number of columns as F has rows, then you can skip f = M\F and go directly to f = F; . That is because in the case of a square matrix the definition of the M\F operator is "as if" inv(M)*F except with higher numeric precision, and you can be sure that inv() of an identity matrix is the same as the identity matrix, leaving you the identity matrix times F, which is going to be just F.
I will create a support case to recommend an improvement to the detection algorithm to make this situation faster.
For a system of equations expressed as
A*x = b;
generally, you should use x = inv(A)*b only if the system is of full rank and is well-conditioned. The inverse of A exists only for well defined full-rank matrices and thus cannot be used for over- or under-defined systems. You should use x=A\b for an over- or under-defined system, or one which is badly conditioned.
For a well defined system, both the methods will yield the same result. The following example illustrates the above:
rand('state',0)A = round(10*rand(4,4)); b = round(20*rand(4,1));
The A and b define a system of equations A*x = b. The RANK function
rank(A) ans = 4
shows that A is a well defined system. The COND function
cond(A) ans = 11.1361
shows that A is fairly well-conditioned. Thus to obtain the solution of the system A*x = b, both the INV function and the backslash operator can be used.
x1 = inv(A)*b x1 = -1.4378 -0.0922 2.2467 1.8038x2 = A\b x2 = -1.4378 -0.0922 2.2467 1.8038
Even though both of the above procedures yield similar results for a well-defined and well-conditioned system, we recommend that you use the '\' operator to solve a system of linear equations, as it will handle both well-conditioned and ill-conditioned matrices robustly and can handle over- or under-determined systems. INV requires the coefficient matrix to be square.
rand('state', 0)A = [round(10*rand(3,4))]; % an over determined system
b = round(10*rand(3,1));
For this example, you cannot use x = inv(A)*b because A is not square. In this case you will have to use x = A\b.
x = A\b x = 1.2400 0.5022 -1.1822 0
More information on the \ operator can be found by typing HELP SLASH at the MATLAB command prompt. More information on kinds of systems is given below.
A system of linear equations can be expressed as one of the following:
(a) Well-defined systems: The system where the number of unknown variables are the same as the number of linearly independent equations (LIE) in the system.
(b) Under-defined systems: The system where the number of unknown variables exceeds the number of LIE relating these variables.
(c) Over-defined systems The system where the number of unknown variables are less then the number of LIE relating these variables.
Mathematically, if A*x = b, then the definition of the system can be obtained as follows:
If A is a square matrix and the rank of A is equal to the length of the matrix, then the matrix is well defined. If A is of size m x n and m>n, then the system is underdefined. If m<n, the system is overdefined.
Best Answer