horzcat-error in subs for certain values

2 views (last 30 days)
Benjamin
Benjamin on 26 Feb 2014
Answered: Benjamin on 28 Feb 2014
Hi everyone,
has anyone an idea on the following problem? I tried to create a minimal example of the problem. But in any more simple form the error does not show up. I wanted to do some matrix algebra and find eigensolutions that match a certain condition. For this i wrote:
syms c a alpha;
A = [ ...
1 , 2*a + 40/2.23; ...
0 , 1 ...
];
B = [ ...
1 , 0; ...
-2/50 , 1 ...
];
C = [ ...
1 , c + (2*a+40+c)/cos(2*alpha); ...
0 , 1 ...
];
D = B*C*B*A;
zr = sqrt(4-(D(1,1)+D(2,2))^2)/(2*D(2,1))-3.15;
z = (D(1,1)-D(2,2))/(2*D(2,1));
laenge = 19;
winkel = 13;
kante = double(solve(subs(zr,[a, alpha],[ laenge , winkel * (pi/180)]) , c));
q = 1/complex(subs( z , [a,alpha,c] , [laenge,winkel*(pi/180),kante] ),opt)
Running this code, i will get a solution without problems. But if i change the variable 'winkel' a little to 13.2 it results in the error
'Error using horzcat. CAT arguments dimensions are not consistent.'
which is pretty weird for me. I was thinking whether my equations maybe don't have solutions for these parameters, but i solved it with the same parameters in mathematica without any problems. Anyone has an idea what i did wrong?
Thanks for your help.
Regards
  2 Comments
Jan
Jan on 26 Feb 2014
Please post the complete error message, which contain a hint to the corresponding line also!
Walter Roberson
Walter Roberson on 27 Feb 2014
Also, please show size() of all variables that appear in the line that is giving the error.

Sign in to comment.

Answers (1)

Benjamin
Benjamin on 28 Feb 2014
Hi everyone,
I added the complete error message, but the hint about the size of the variables brought the solution. The variable 'kante' had two solutions after solving the given equation. In Mathematica i considered this by choosing one of the solutions. Here I didn't. Now I do and it works fine.
Thanks!

Categories

Find more on Symbolic Math Toolbox 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!