How to solve equations in variable terms?

4 views (last 30 days)
I wanted to find equation solving a, b, c, and d in terms of e, f, g, and h. Is it possible to do this in MATLAB? Here's my code for the moment.
clc
clear all
syms a b c d e f g h alpha
A = [a b; c d];
R = [cos(alpha) -sin(alpha); sin(alpha) cos(alpha)];
D = (R*A)*transpose(R);
e=D(1,1)
e = 
f=D(1,2)
f = 
g=D(2,1)
g = 
h=D(2,2)
h = 
eqn=[e f g h];
solver=solve(eqn,[a b c d])
solver = struct with fields:
a: 0 b: 0 c: 0 d: 0

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 21 Apr 2023
syms a b c d e f g h alpha
A = [a b; c d];
R = [cos(alpha) -sin(alpha); sin(alpha) cos(alpha)];
D = (R*A)*transpose(R);
%Modify the equations
eq1 = e-D(1,1)==0;
eq2 = f-D(1,2)==0;
eq3 = g-D(2,1)==0;
eq4 = h-D(2,2)==0;
eqn=[eq1 eq2 eq3 eq4];
solver=solve(eqn,[a b c d])
solver = struct with fields:
a: (e*cos(alpha)^2 + h*sin(alpha)^2 + f*cos(alpha)*sin(alpha) + g*cos(alpha)*sin(alpha))/(cos(alpha)^2 + sin(alpha)^2)^2 b: (f*cos(alpha)^2 - g*sin(alpha)^2 - e*cos(alpha)*sin(alpha) + h*cos(alpha)*sin(alpha))/(cos(alpha)^2 + sin(alpha)^2)^2 c: (g*cos(alpha)^2 - f*sin(alpha)^2 - e*cos(alpha)*sin(alpha) + h*cos(alpha)*sin(alpha))/(cos(alpha)^2 + sin(alpha)^2)^2 d: (h*cos(alpha)^2 + e*sin(alpha)^2 - f*cos(alpha)*sin(alpha) - g*cos(alpha)*sin(alpha))/(cos(alpha)^4 + sin(alpha)^4 + 2*cos(alpha)^2*sin(alpha)^2)

More Answers (0)

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!