Solve a matricial equation, i.e a system of 16 equations with 16 unknown : Error when call solve function

조회 수: 4 (최근 30일)
I wonder under which conditions I could have equality between the 2 matrices 4x4.
I build my 2 matrixes from which I would like to get an equality. But to get this equality, I have to solve an unknow matrix 4x4 whose terms are present in the 2 matrices 4x4.
To show you a practical example, I put below a small Matlab script that tries to follow all the reasoning explained above :
clear;
clc;
% Big_1 Fisher :
FISH_Big_1_SYM = sym('sp_', [5,5], 'real');
% Force symmetry for Big_1
FISH_Big_1_SYM = tril(FISH_Big_1_SYM.') + triu(FISH_Big_1_SYM,1);
% Big_2 Fisher :
FISH_Big_2_SYM = sym('sp_', [5,5], 'real');
% Force symmetry for Big_2
FISH_Big_2_SYM = tril(FISH_Big_2_SYM.') + triu(FISH_Big_2_SYM,1);
% Jacobian 1
J_1_SYM = sym('j_', [5,5], 'real');
% Jacobian 2
J_2_SYM = sym('j_', [5,5], 'real');
% Remove 4th row/column
J_2_SYM(4,:) = [];
J_2_SYM(:,4) = [];
%%%%%%%% Method 1 : projection before marginalisation %%%%%%%%%
% Projection
FISH_proj_1 = J_1_SYM'*FISH_Big_1_SYM*J_1_SYM;
% Check size : 5x5
size(FISH_proj_1)
% Invert Fisher_2
COV_Big_1_SYM = inv(FISH_Big_1_SYM);
% Marginalisation
COV_Big_1_SYM(4,:) = [];
COV_Big_1_SYM(:,4) = [];
FISH_Big_1_SYM = inv(COV_Big_1_SYM);
%%%%%%%% Method 2 : projection after marginalisation %%%%%%%%%
% Invert Fisher_2
COV_Big_2_SYM = inv(FISH_Big_2_SYM);
% Remove 4th row/column
COV_Big_2_SYM(4,:) = [];
COV_Big_2_SYM(:,4) = [];
% Re-inverse
FISH_Big_2_SYM_new = inv(COV_Big_2_SYM);
% Projection 2x2
FISH_proj_2 = J_2_SYM'*FISH_Big_2_SYM_new*J_2_SYM;
% Check size : 4x4
size(FISH_proj_2)
% Remove 4th row/column of Fisher matrix method 1
FISH_proj_1(4,:) = [];
FISH_proj_1(:,4) = [];
% Test equality between 2 matrices
isequal(FISH_proj_1,FISH_proj_2);
% Matricial equation to solve
eqn = FISH_proj_1 == FISH_proj_2;
% Solving : Jacobian 4x4 unknown
[solx, parameters, conditions] = solve(eqn, J_2_SYM, 'ReturnConditions', true);
solx
Once I finsished to build my 2 matrices FISH_proj_1 and FISH_proj_2, I get the error in "solve" function :
Error using sym/solve (line 279)
Inconsistent output with 1 variables for input argument with 16 variables.
Error in demo_projection_dev (line 62)
[solx, parameters, conditions] = solve(eqn, J_2_SYM, 'ReturnConditions', true);
The unknown is a Matrix 4x4 named J_2_SYM.
How to debug this error with solve function ? Is the syntaw right if I put J_2_SYM directly in solve function call ?
Best regards

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by