# Solve an algebraic matrix equation

2 views (last 30 days)
Vincent Ike on 13 Jul 2021
Commented: Vincent Ike on 16 Jul 2021
Please I need help to obtain the variables (U, V, W, Th) as the solution of the matrix algebra equation below, say
syms U V W Th
a24 = 0:0.2:5; % which is a step forcing function (in time)
F = rand(4,4)*[U; V; W; Th] - [zeros(4,2), rand(4,2)]*[0; 0; W^2; Th^2] - [zeros(2,26); a24; a24];
Error using symengine (line 59)
Array sizes must match.
Error in sym/privBinaryOp (line 903)
Error in - (line 7)
X = privBinaryOp(A, B, 'symobj::zip', '_subtract');
I get stuck trying to subtract a 4 by 1 symbol affiliated matrix columnwise from a double 4 by 26 matrix, so that I can obtain the variables using
FF = solve(F == 0,[U,V,W,Th])
I need help with this problem please. Thanks in anticipation.
Vincent Ike on 14 Jul 2021
Yes @walter Roberson I use R2015a

Walter Roberson on 13 Jul 2021
The operation is permitted in current versions:
syms U V W Th
a24 = 0:0.2:5; % which is a step forcing function (in time)
F = rand(4,4)*[U; V; W; Th] - [zeros(4,2), rand(4,2)]*[0; 0; W^2; Th^2] - [zeros(2,26); a24; a24]
F =
You did not mark your release or mention your release, so the volunteers are entitled to expect that you are using the newest version.
However, I happen to recognize the issue: in sufficiently old versions of MATLAB, implicit expansion did not exist. Furthermore, in old enough versions, bsxfun() could not be used for symbolic expressions.
In versions that old, you have to repmat()
F = repmat(rand(4,4)*[U; V; W; Th] - [zeros(4,2), rand(4,2)]*[0; 0; W^2; Th^2], 1, 26) - [zeros(2,26); a24; a24]
F =
Vincent Ike on 16 Jul 2021
Thank you Walter, I have got much insight with your responses. Now, I have a good question here, https://www.mathworks.com/matlabcentral/answers/879973-how-to-solve-four-sets-of-ode-having-four-variables. I hope to learn more from you.

R2015a

### Community Treasure Hunt

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

Start Hunting!