Why the result of my code is empty matrices?

조회 수: 4 (최근 30일)
Faezeh Manesh
Faezeh Manesh 2021년 4월 6일
답변: Vishesh 2023년 9월 20일
Hi,
I am trying to solve a system of nonlinear equations using the folowing code. When I run my code it gives me empty matrices. Can someone help me why this happens and how I can fix this problem?
clc
clear all
syms a1 a2 a3 b1 b2 b3 c1 c2 c3
a3=0;
b3=0;
m1=0.894;
m2=0.894;
m3=1.252;
eq1 = a1*a2+b1*b2+c1*c2==0;
eq2 = a2*a3+b2*b3+c2*c3==0;
eq3 = a1*a3+b1*b3+c1*c3==0;
eq4 = (a1)^2+(b1)^2+(c1)^2==1;
eq5 = (a2)^2+(b2)^2+(c2)^2==1;
eq6 = (a3)^2+(b3)^2+(c3)^2==1;
M1=[a1*a1 a1*b1 a1*c1;a1*b1 b1*b1 b1*c1;a1*c1 b1*c1 c1*c1];
M2=[a2*a2 a2*b2 a2*c2;a2*b2 b2*b2 b2*c2;a2*c2 b2*c2 c2*c2];
M3=[a3*a3 a3*b3 a3*c3;a3*b3 b3*b3 b3*c3;a3*c3 b3*c3 c3*c3];
M = m1*M1+m2*M2+m3*M3;
eq7 = det(M)==1;
eqns = [eq1 eq2 eq3 eq4 eq5 eq6 eq7];
vars = [a1 a2 b1 b2 c1 c2 c3];
[S_a1, S_a2, S_b1, S_b2, S_c1, S_c2, S_c3] = solve(eqns,vars);
Thanks,
Faezeh

답변 (1개)

Vishesh
Vishesh 2023년 9월 20일
I understand that you are getting empty matrices on executing your code.
I would like to inform you that "solve()" function returns empty matrices when no solutions exist for the given equations.
To resolve this issue , please double-check your equations and run your code again.
For more information on "solve()" function, please refer to the following documentation:

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by