- What you want to do, including a short description of the problem you are solving
- What you are doing (describe your design and the functions you use)
- What is not working
- Everything in any error messages (red type in the Command Window) if it is generating errors
- What lines and variables we particularly need to pay attention to
Find all solutions of a system of equations
5 次查看(过去 30 天)
显示 更早的评论
I have a problem in which i need to find the maximum of the function "V". For those positive values to be the global maximum of the function, the three conditions c1, c2 and c3 must be positive. With the first values determined by solve function i dont't get the global maximum becuse c1, c2 and c3 are not verified. How do i get more solutions? This function has a global maximum. I'm pretty sure about that.
The code is:
if true
clear
clc
P=2000;
L=1300;
sa=150;
syms a b positive all
%se definesc lungimiile elementelor
l1=L/sin(45*pi/180);
l2=L/cos(a*pi/180);
l3=L/cos((a+b)*pi/180);
%eforturile din bare(la ridicarea nedeterminari)
N3(a,b)=(P*cos(a*pi/180))/(cos(a*pi/180)*sin((a+b)*pi/180)-(cos((a+b)*pi/180)*sin(a*pi/180)));
N2(a,b)=((-N3*cos((a+b)*pi/180)))/(cos(a*pi/180));
n3(a,b)=(-sin((a+45)*pi/180))/sin(b*pi/180);
n2(a,b)=(cos(45*pi/180)-n3*cos((a+b)*pi/180))/cos(a*pi/180);
%coeficientii ecuatiei canonice
D1F(a,b)=l2*n2*N2+l3*n3*N3;
d11(a,b)=l1+l2*n2*n2+l3*n3*n3;
%calcularea eforturilor nodale;
X1(a,b)=-D1F/d11;
X3(a,b)=(P*cos(a*pi/180)-X1*sin((45+a)*pi/180))/sin(b*pi/180);
X2(a,b)=(X1*cos(45*pi/180)-X3*cos((a+b)*pi/180))/cos(a*pi/180);
%functia obiectiv;
V(a,b)=(X1/sa)*l1+(X2/sa)*l2+(X3/sa)*l3;
%derivarea functiei obiectiv
diff_f1=diff(V,a);
diff_f2=diff(V,b);
%Calcularea valorilor numerice
[a, b]=solve(diff_f1, diff_f2)
%conditiilor de maxim global;
conditie1=diff(V,'a',2);
conditie2=diff(V, 'b', 2);
conditie3_1=diff(V, 'a', 'b');
conditie3=conditie1*conditie2-conditie3_1;
%verificarea conditiilor de maxim global
c1=double(conditie1(a,b))
c2=double(conditie2(a,b))
c3=double(conditie3(a,b))
if c1>0, c2>0, c3>0;
disp('Cele 3 condititii sunt verificate, astfel solutiile obtinute reprezinta punctul de maxim global')
end
%calcularea eforturilor nodale
F1=double(X1(a,b))
F2=double(X2(a,b))
F3=double(X3(a,b))
%Se verifica daca valorile obtinute pentru eforturile nodale verifica
%ecuatia de echilibru a fortelor pe directia Y
ver_ec=double(F1*sin(45*pi/180)+F2*sin(a*pi/180)+F3*sin((a+b)*pi/180)) end
3 个评论
John D'Errico
2014-5-4
Why do people feel it necessary to wrap their code with an "if true" block?
This is a waste of bits.
Image Analyst
2014-5-4
John, it's because they clicked {}Code before they pasted their code in instead of after . It would be best if that button warned them to paste in code first, instead of putting in "if true" (Randy, are you listening?)
回答(1 个)
John D'Errico
2014-5-4
编辑:John D'Errico
2014-5-4
There is a global optimization toolbox. Use it.
If you don't have it and won't buy it, then start your optimizer with various random start points. Note that my rmsearch tool (found on the file exchange) does this for you.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!