Simplify matrix of symbolic equations

2 次查看(过去 30 天)
Hi,
I have an array M with symbolic equations in each field. For example: M(1, 1) = -w2^2 -w3^2 +1.
Additionally I know that norm(w) == 1 (with w = [w1, w2, w3]).
Therefore I could simplify M(1, 1) to just w1^2.
How do I get MATLB to this for me? I have tried to use 'solve' and 'simplify' for this task but didn't figure out how to specify the inputs correctly. I also tried using assumptions.
  1 个评论
Philipp Kutschmann
Philipp Kutschmann 2022-6-14
ok, I have constructed a even more minimal example:
syms x1 x2 f1 f2
f1 = x1 + x2 == 1
f2 = 2*x1 + 3*x2
normally I could simplify f2 to f2 = x2 + 2 by rearaning f1 and plugging it in for x1. I wasn't able to find a Matlab function that does that for me. Simplify only let's you take one input function and Solve seems to give me random values for x1 and x2 that satisfy f1.

请先登录,再进行评论。

回答(1 个)

Torsten
Torsten 2022-6-14
syms x1 x2 f1 f2
f1 = x1 + x2 == 1;
f2 = 2*x1 + 3*x2;
x1s = solve(f1,x1);
f2 = subs(f2,x1,x1s)
f2 = 

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by