Solve a system of 3 equations with 3 unknowns

조회 수: 4 (최근 30일)
Pavel
Pavel 2014년 4월 4일
댓글: Pavel 2014년 4월 5일
I have the folowing code. My 3 equations are diff_f1, diff_f2 and diff_f3 with the unkowns a,b,c. I need to make the equations equal to 0 and to solve for a,b and c, but when i do that i obtain that a=b=c=0 and that are not the answers i'm looking for. What i'm doing wrong and how i can solve these equations?
if true
clear all
clc
% a=alpha1; b=alpha2; c=betha
syms a b c d N1 N2 N3 N21 N31 n2 n21 n3 l1 l2 l3 P L sa
% Se calculeaza lungimea elementelor
P=2000;
L=1300;
sa=150;
l1=L/cos(a);
l2=L/cos(b);
l3=L/cos(b+c);
d=a+b;
% Se calculeaza A
N21=(-P*cos(b+c)/(cos(b)*sin(b+c)-cos(b+c)));
N31=P/(sin(b+c)-cos(b+c)/cos(b));
n31=(-sin(a)*cos(b)-sin(b)*cos(a))/(sin(b+c)*cos(b)-cos(b+c)*sin(b));
n3=n31;
n21=(cos(a)-n3*cos(b+c))/cos(b);
n2=n21;
%efortul din elementul 1
N1=(-((n2*l2*N21+n3*l3*N31)/(l1+n2^2*l2*n3^2*l3)));
%efortul din elementul 3
N3=(P*cos(b)-N1*sin(a)*cos(b)-N1*cos(a))/(cos(b)*(sin(b+c)-cos(b+c)));
%efortul din elementul 2
N2=(N1*cos(a)-cos(b+c)*N3)/(cos(b));
%definrea functiei obiectiv
V1=((N1/sa)*l1+(N2/sa)*l2+(N3/sa)*l3);
%diff(V(a,b,c),a)
V=simplify(V1);
diff_f1=diff(V,a);
diff_f2=diff(V,b);
diff_f3=diff(V,c);
[a b c]=solve('diff_f1=0','diff_f2=0','diff_f3=0');
end

채택된 답변

Walter Roberson
Walter Roberson 2014년 4월 4일
[a, b, c] = solve(diff_f1, diff_f2, diff_f3);
  댓글 수: 5
Walter Roberson
Walter Roberson 2014년 4월 5일
Which MATLAB release are you using?
In the meantime try
feval(symengine, 'numeric::solve', [diff_f1, diff_f2, diff_f3], [a b c], [-2*pi 2*pi])
Pavel
Pavel 2014년 4월 5일
i'm using R2012a

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by