Error using sym/cat>checkDimensions CAT arguments dimensions not consistent.
5 views (last 30 days)
Show older comments
I don't understand why I get this error when executing the following code. C1 and C2 are 3x3 matrices defined before.
Error using sym/cat>checkDimensions
CAT arguments dimensions not consistent.
Error in sym/cat>catMany (line 33)
[resz, ranges] = checkDimensions(sz,dim);
Error in sym/cat (line 25)
ySym = catMany(dim, args);
Error in sym/horzcat (line 19)
ySym = cat(2,args{:});
Error in proj (line 120)
res = solve([eq1, eq2, eq3, eq4, eq5], [l11, l12, l13, l21, l22, l23, l31, l32, l33, l41, l42, l43, v11, v12, v13, v21, v22, v23])
syms l11 l12 l13
syms l21 l22 l23
syms l31 l32 l33
syms l41 l42 l43
syms v11 v12 v13
syms v21 v22 v23
eq1 = [l11; l12; l13] == C1 * [v11; v12; v13];
eq2 = [l21; l22; l23] == C1 * [v21; v22; v23];
eq3 = [l31; l32; l33] == C2 * [v11; v12; v13];
eq4 = [l41; l42; l43] == C2 * [v21; v22; v23];
eq5 = sqrt((v11/v13-v21/v23)^2 + (v12/v13-v22/v23)^2) > 100;
res = solve([eq1, eq2, eq3, eq4, eq5], [l11, l12, l13, l21, l22, l23, l31, l32, l33, l41, l42, l43, v11, v12, v13, v21, v22, v23])
0 Comments
Answers (1)
Walter Roberson
on 1 Jan 2023
syms l11 l12 l13
syms l21 l22 l23
syms l31 l32 l33
syms l41 l42 l43
syms v11 v12 v13
syms v21 v22 v23
syms C1 C2
eq1 = [l11; l12; l13] == C1 * [v11; v12; v13];
eq2 = [l21; l22; l23] == C1 * [v21; v22; v23];
eq3 = [l31; l32; l33] == C2 * [v11; v12; v13];
eq4 = [l41; l42; l43] == C2 * [v21; v22; v23];
eq5 = sqrt((v11/v13-v21/v23)^2 + (v12/v13-v22/v23)^2) > 100;
whos eq1 eq2 eq3 eq4 eq5
eq1, eq2, eq3, eq4 are systems of 3 x 1 equations. eq5 is 1 x 1. You are trying to [] them together.
res = solve([eq1, eq2, eq3, eq4, eq5], [l11, l12, l13, l21, l22, l23, l31, l32, l33, l41, l42, l43, v11, v12, v13, v21, v22, v23])
1 Comment
Walter Roberson
on 1 Jan 2023
syms l11 l12 l13
syms l21 l22 l23
syms l31 l32 l33
syms l41 l42 l43
syms v11 v12 v13
syms v21 v22 v23
syms C1 C2
eq1 = [l11; l12; l13] == C1 * [v11; v12; v13];
eq2 = [l21; l22; l23] == C1 * [v21; v22; v23];
eq3 = [l31; l32; l33] == C2 * [v11; v12; v13];
eq4 = [l41; l42; l43] == C2 * [v21; v22; v23];
eq5 = sqrt((v11/v13-v21/v23)^2 + (v12/v13-v22/v23)^2) > 100;
whos eq1 eq2 eq3 eq4 eq5
res = solve([eq1; eq2; eq3; eq4; eq5], [l11, l12, l13, l21, l22, l23, l31, l32, l33, l41, l42, l43, v11, v12, v13, v21, v22, v23])
You are trying to solve a system of 13 equations for 18 variables, which is not something that MATLAB can do.
You can try to solve for 13 of the variables
res = solve([eq1; eq2; eq3; eq4; eq5], [l11, l12, l13, l21, l22, l23, l31, l32, l33, l41, l42, l43, v11])
subs([l11, l12, l13, l21, l22, l23, l31, l32, l33, l41, l42, l43, v11], res)
You might be able to squeeze out one more variable, but I doubt it.
Note that MATLAB tends to give misleading answers when you solve inequalities. MATLAB tends to present the answers in definite form, as if the return values are the only ones that satisfy the equations. However when inequalities are present, the result given by solve() might be representative rather than complete. For example if you solve for x^2 >= 0 then instead of given an answer of "z" with condition "z element R" it might pick the specific value 0 .
The internal symbolic engine is returning the general solution; it is the interface to the MATLAB presentation level that is stripping out the inequalities and replacing them with representative values.
syms x
solve(x^2>=0)
char(feval(symengine, 'solve', x^2>=0))
See Also
Categories
Find more on Equation Solving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!