How to solve equations in variable terms?

1 回表示 (過去 30 日間)
yehuda kristo
yehuda kristo 2023 年 4 月 21 日
コメント済み: yehuda kristo 2023 年 4 月 21 日
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

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 4 月 21 日
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)
  1 件のコメント
yehuda kristo
yehuda kristo 2023 年 4 月 21 日
Oh okay it needs to be specified that way. Thanks Sir

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by