假设我在3个变量中有2个符号方程式:
syms u v w
eq1 = u+v+w == 0
eq2 = w == 0
两者都应该等于0。 有没有办法将这些方程式提供给Matlab并让Matlab得出结论:
u=-v
w=0
我尝试了以下内容:
%Attempt 1:
x=solve([eq1 eq2],[u v w]);
x.u, x.v, x.w
%Outputs 0 for each of these
% Attempt 2:
[A,B]=equationsToMatrix([eq1 eq2],[u v w]);
linsolve(A,B)
%Outputs 0 for all variables and gives a warning "Warning: The system is rank-deficient. Solution is not unique."
所以它似乎只能返回微不足道的零解决方案。这当然是一个基本的例子。我希望它适用于81个交织在一起的变量。
答案 0 :(得分:1)
由于你有两个方程,你只能求解两个变量,而不是三个。您希望看到u=-v
和w=0
,这是u
和w
中的解决方案,但不是v
中的解决方案。
对我x = solve([eq1,eq],u,w)
有效,它会x.u=-v
和x.w=0
。