How can I extract two matrices 6x6(unknown) and 6x1(known) multiplied together to form 6x1(known) matrix. As it isn't a square matrix I cannot perform inverse. Kindly suggest what can be done

11 vues (au cours des 30 derniers jours)
How can I extract two matrices 6x6(unknown) and 6x1(known) multiplied together to form a 6x1(known) matrix? As 6x1 isn't a square matrix I cannot perform inverse. Kindly suggest what can be done

Réponses (2)

Stephan
Stephan le 8 Nov 2018
Modifié(e) : Stephan le 8 Nov 2018
Hi,
there is not a unique solution. Here is an Approach with fsolve, which gives one solution. I used an example to find a 3x3 matrix:
% Define a Matrix to calculate x
M = [1 -2 7; 2 5 2; 4 3 -1]
% Define b
b = [2; -4; 3]
% Calculate x --> Solution to the system
x = M\b
% run fsolve to find Matrix which meets the conditon A*x = b
A0 = eye(3);
fun = @(A)([A(1) A(4) A(7); A(2) A(5) A(8); A(3) A(6) A(9)]*x)-b;
A = fsolve(fun,A0)
% Test the result --> it should be the same as b
A*x
Note that you get another valid solution if you change x0 and that the indexing of the objective function for all A(i) follows the indexing rules of Matlab. In this configuration i got pretty good results for this example with 9 unknown values, beside the numerical rounding errors and the tolerances from fsolve.
Best regards
Stephan

John D'Errico
John D'Errico le 25 Mai 2021
I am way too late for a useful answer. As has been said, the solution is not unique. (You do not need to use fsolve.)
I'll assume you are given a 6x1 vector V, And a 6x1 vector U. These are known. Now you want to find a 6x6 MATRIX X, that will satisfy the equality
X*V = U
A simple trick is to use pinv. I'll give an example. Since I have no data, I'll just make up some random numbers.
U = randn(6,1)
U = 6×1
-0.3420 -0.2240 0.1463 -0.2547 0.4231 0.5700
V = randn(6,1)
V = 6×1
-0.1025 0.1211 1.0201 1.6752 -1.5332 0.6471
Now, can we find a matrix X, such that A*V==U? This is as simple as one line of code.
X = U*pinv(V)
X = 6×6
0.0053 -0.0062 -0.0525 -0.0863 0.0790 -0.0333 0.0035 -0.0041 -0.0344 -0.0565 0.0517 -0.0218 -0.0023 0.0027 0.0225 0.0369 -0.0338 0.0143 0.0039 -0.0046 -0.0391 -0.0643 0.0588 -0.0248 -0.0065 0.0077 0.0650 0.1067 -0.0977 0.0412 -0.0088 0.0104 0.0876 0.1438 -0.1316 0.0555
X will be the smallest such matrix that will satisfy the requirement, smallest in terms of the overall size of the numbers in that matrix.
norm(X*V - U)
ans = 6.2063e-17
So, to within floating point trash, X does solve the problem, and it was found trivially easy.
There are infinitely many solutions. But X as found will be the one with smallest norm.

Community Treasure Hunt

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

Start Hunting!

Translated by