How to find solutions for a matrix equality, i.e a system of equations ?

1 次查看(过去 30 天)
I would like to make work a small script. This Matlab code is expected to solve a matricial equation, but by equality of 2 final matrixes, this is about solve 4 equations with 3 unknown (since I have initially an array of 2x2 unknown but this matrix of unknown is symmetric, so actually there are 3 unkonwns).
But for the moment, Matlab doesn't succeed in finding the solutions.
Here is the Matlab script :
clear;
clc;
format long;
% 2 Fisher Matrixes symbolic : FISH_GCsp_SYM, : 1 cosmo params + 1 bias spectro put for common
% FISH_XC_SYM : 1 cosmo params + 2 bias photo correlated
% Spectro
% First parameter : cosmo , second : bias spectro
FISH_GCsp_SYM = sym('sp1_', [4,4], 'real');
FISH_GCsp_SYM(3:4,3:4) = 0
FISH_GCsp_SYM(1:2,3:4) = 0
FISH_GCsp_SYM(3:4,1:2) = 0
% Force symmetry
FISH_GCsp_SYM = tril(FISH_GCsp_SYM.') + triu(FISH_GCsp_SYM,1)
% First parameter : cosmo , second : 2 bias photo correlated
FISH_XC_SYM = sym('xc1_', [3,3], 'real');
FISH_XC_SYM(1,2) = 0;
FISH_XC_SYM(2,1) = 0;
FISH_XC_SYM(2,2) = 0;
FISH_XC_SYM = tril(FISH_XC_SYM.') + triu(FISH_XC_SYM,1);
% FISH_ALL1 : brutal marginalization on Fisher matrix
FISH_ALL1(1:2,1:2) = FISH_GCsp_SYM(1:2,1:2) + FISH_XC_SYM(1:2:3);
% FISH_SYM2 : from big Fisher matrix
FISH_GCsp_SYM = sym('sp1_', [4,4], 'real');
FISH_GCsp_SYM(3:4,3:4) = 0;
FISH_GCsp_SYM(1:2,3:4) = 0;
FISH_GCsp_SYM(3:4,1:2) = 0;
% Force symmetry
FISH_GCsp_SYM = tril(FISH_GCsp_SYM.') + triu(FISH_GCsp_SYM,1);
% First parameter : cosmo , second : 2 bias photo correlated
FISH_XC_SYM = sym('xc1_', [4,4], 'real');
%FISH_XC_ADD2 = sym('eps_xc_', [3,3], 'real');
FISH_XC_SYM(1,2) = 0;
FISH_XC_SYM(2,1) = 0;
FISH_XC_SYM(2,2) = 0;
FISH_XC_SYM = tril(FISH_XC_SYM.') + triu(FISH_XC_SYM,1);
% Adding new observable "O" terms
FISH_O_SYM = sym('o_', [2,2], 'real');
FISH_O_SYM = tril(FISH_O_SYM.') + triu(FISH_O_SYM,1);
% Addition of second Fisher matrix
FISH_SYM2 = FISH_GCsp_SYM + FISH_XC_SYM;
FISH_SYM2(2,2) = FISH_SYM2(2,2) + FISH_O_SYM(1,1);
FISH_SYM2(3,3) = FISH_SYM2(3,3) + FISH_O_SYM(2,2);
FISH_SYM2(2,3) = FISH_SYM2(2,3) + FISH_O_SYM(1,2);
FISH_SYM2(3,2) = FISH_SYM2(3,2) + FISH_O_SYM(2,1);
% Marginalize FISH_SYM2 in order to get back a 2x2 matrix
% Invert to marginalyze
COV_ALL = inv(FISH_SYM2);
% Marginalize
COV_ALL([3,4],:) = [];
COV_ALL(:,[3,4]) = [];
FISH_ALL2 = inv(COV_ALL);
FISH_ALL1
FISH_ALL2
% Matricial equation to solve
eqn = FISH_ALL1 == FISH_ALL2;
% Solving : matrix1 equal to matrix2
sol = solve(eqn, [FISH_O_SYM(1,1),FISH_O_SYM(2,2),FISH_O_SYM(1,2)]);
You can try it and see there are no found solutions. The context is about Fisher formalism. From my first analysis, I get 2 matrixes which have to be equal. I introduce in the second the unkonws o_1_1, o_1_2 and o_2_2 : So finally, I have a system of 4 equations with 3 unknows to solve.
If someone could help me to fix it, I would be grateful.
  3 个评论
petit
petit 2021-4-12
编辑:petit 2021-4-13
Sorry, I did a mistake in the initial script.
Now, I get the following system of equations with unknows o_1_1, o_1_2, o_2_1 and o_2_2 :
FISH_ALL1 =
[ sp1_1_1 + xc1_1_1, sp1_1_2 + xc1_1_3]
[ sp1_1_2 + xc1_1_1, sp1_2_2 + xc1_1_3]
FISH_ALL2 =
[ -(o_2_2*xc1_1_4^2 + sp1_1_1*xc1_3_4^2 + xc1_1_1*xc1_3_4^2 + xc1_1_4^2*xc1_3_3 + xc1_1_3^2*x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)/(- xc1_3_4^2 + o_2_2*xc1_4_4 + xc1_3_3*xc1_4_4)]

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matched Filter and Ambiguity Function 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by