How do I solve these systems of equations? Keep getting empty matrices.
Show older comments
So here are the two equations:
(1−e^φ )*P = (1−e^β )*G + (e^β)*(1−e^α)*W
α = φ −β
Where φ = 90 and P,G and W are 1x2 matrices of [2,1], [0,0] and [1.3822, 1.3822] respectively.
Here is my code:
function y = RR2CrankAng(P12,G,W1,theta12)
syms beta12 alpha12
eqn1 = ((1-exp(theta12))*P12) == ((1-exp(beta12))*G)+((exp(beta12))*(1-exp(alpha12))*W1);
eqn2 = alpha12 == theta12 - beta12;
sol = solve([eqn1, eqn2], [beta12, alpha12]);
xSol = sol.beta12;
ySol = sol.alpha12;
y = [xSol,ySol];
end
calling it
CA = RR2CrankAng(P12,G,W1,theta12)
CA =
Empty sym: 0-by-2
What is happening here?
Answers (1)
Roger Stafford
on 18 May 2016
Edited: Roger Stafford
on 18 May 2016
If you specify theta12 as a known, as you have done, you have in effect three equations to solve and only two unknowns. I think ‘solve’ will object to that. In any case, there is a way of solving these without the use of ‘solve’. Consider x = exp(beta) as one unknown and y = exp(phi) as the other unknown. Then you have two linear equations
(1-y)*P(1) = (1-x)*G(1)+(x-y)*W(1)
(1-y)*P(2) = (1-x)*G(2)+(x-y)*W(2)
which can easily be solved for x and y using the backslash operator. From the values of x and y, you can get alpha and beta using:
beta = log(x)
alpha = log(y)-beta
2 Comments
S R
on 19 May 2016
Roger Stafford
on 19 May 2016
Edited: Roger Stafford
on 19 May 2016
The equations
(1-y)*P(1) = (1-x)*G(1)+(x-y)*W(1)
(1-y)*P(2) = (1-x)*G(2)+(x-y)*W(2)
can be translated to
(G(1)-W(1))*x + (W(1)-P(1))*y = G(1)-P(1)
(G(2)-W(2))*x + (W(2)-P(2))*y = G(2)-P(2)
and expressing this as a problem in matlab gives the matrix equation
[G(:)-W(:),W(:)-P(:)]*XY = [G(:)-P(:)]
where XY is the unknown column matrix [x;y]. Its solution is
XY = [G(:)-W(:),W(:)-P(:)]\[G(:)-P(:)] = [1;1]
for which x = 1 and y = 1. This corresponds to the trivial solution β = 0, φ = 0, and α = 0. Somehow I doubt if you expected this as an answer, but if you go back and substitute those values in, you will see that it is actually valid.
As to your question about
(e^β)*(1−e^α)*W ==> (x-y)*W(1)
this is equivalent to
(e^β-e^(α+β))*W = (e^β-e^φ)*W = (x-y)*W
I think I have already explained why I think you are getting empty solutions from 'solve'. You are presenting it with more equations than unknowns, which 'solve' is unhappy with.
Categories
Find more on Linear Algebra 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!