MATLAB Answers

Error when trying to solve a "Matricial" equation : problem of indices

1 view (last 30 days)
petit
petit on 14 Feb 2021
Edited: petit on 14 Feb 2021
Hello,
I try to solve a system of equations (actually, this is like a "Matricial equations since I would like that each elements of 2 matrices to be equal)
The 2 matrices to be equal are named :
FISH_GCsp_XC_SYM
and
FISH_GCsp_XC_SYM2
I have just put a crucial constraint in my system, i.e :
% Set 1 bias spectro equal for sp and xc
FISH_GCsp_SYM(8,:) = FISH_XC_SYM(8,:)
FISH_GCsp_SYM(:,8) = FISH_XC_SYM(:,8)
Here is the entire scrit :
FISH_GCsp_SYM = sym('sp_', [8 8])
FISH_XC_SYM = sym('xc_', [8 8])
FISH_GCsp_SYM2 = sym('sp2_', [9 9])
FISH_XC_SYM2 = sym('xc2_', [9 9])
% Set 1 bias spectro equal for sp and xc
FISH_GCsp_SYM(8,:) = FISH_XC_SYM(8,:)
FISH_GCsp_SYM(:,8) = FISH_XC_SYM(:,8)
% Sum for Fisher matrices;
FISH_GCsp_XC_SYM = FISH_GCsp_SYM + FISH_XC_SYM;
% Marginalisation on 9th dimension
COV_GCsp_SYM2 = inv(FISH_GCsp_SYM2)
COV_XC_SYM2 = inv(FISH_XC_SYM2)
COV_GCsp_SYM2(9,:) = [];
COV_GCsp_SYM2(:,9) = [];
COV_XC_SYM2(9,:) = [];
COV_XC_SYM2(:,9) = [];
FISH_GCsp_SYM2 = inv(COV_GCsp_SYM2);
FISH_XC_SYM2 = inv(COV_XC_SYM2);
% Sum for Fisher matrices;
FISH_GCsp_XC_SYM2 = FISH_GCsp_SYM2 + FISH_XC_SYM2;
% Matricial equality
eqn = FISH_GCsp_XC_SYM == FISH_GCsp_XC_SYM2;
% Solving : matrix1 equal to matrix2
sol = solve([eqn(:)], FISH_GCsp_XC_SYM(:,8))
The unknown to determine symbolicly is the last colum of FISH_GCsp_XC_SYM , i.e FISH_GCsp_XC_SYM(:,8) (so 8 unknown at total).
Unfortunately, I get the following error at execution :
Error using sym.getEqnsVars>checkVariables (line 92)
Second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 54)
checkVariables(vars);
Error in solve>getEqns (line 429)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in building_observable_to_find_SIMPLE_EXAMPLE_ONLY_1_BIAS_COMMON (line 190)
sol = solve([eqn(:)], FISH_GCsp_XC_SYM(:,8))
I don't understand why it fails.
If someone could tell me what's wrong, this would be fine.
Best regards

Answers (2)


petit
petit on 14 Feb 2021
@Walter Roberson , Thanks for your quick answer.
I tried like you suggested :
eqn = FISH_GCsp_XC_SYM == FISH_GCsp_XC_SYM2;
% Solving : matrix1 equal to matrix2
sol = solve([eqn(:)], FISH_GCsp_XC_SYM(:,8))
But I get this error :
Error using sym.getEqnsVars>checkVariables (line 92)
Second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 54)
checkVariables(vars);
Error in solve>getEqns (line 429)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in building_observable_to_find_SIMPLE_EXAMPLE_ONLY_1_BIAS_COMMON (line 190)
sol = solve([eqn(:)], FISH_GCsp_XC_SYM(:,8))
What do you think about this error message ? How to circumvent it ?
Regards

Community Treasure Hunt

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

Start Hunting!