I can't execute this code. I am trying to use fsolve to solve my nonlinear equations
1 次查看(过去 30 天)
显示 更早的评论
Here is my Functions Code
clc
syms gamma
syms E
syms alpha
syms beta
syms Sut
syms l1
syms l2
syms l3
syms delta_l1
syms delta_l2
syms delta_l3
syms delta_h
syms delta_v
syms P1
syms P2
syms P3
syms Fh
syms Fv
syms P_1
syms P_2
syms P_3
syms alpha_1
syms beta_1
syms gamma_1
E = 1e9
Sut = 1e8
Area = 1e-4
alpha = 30
beta = 45
gamma = 60
l1 = 1/sind(alpha)
l2 = 1/sind(beta)
l3 = 1/sind(gamma)
G = E*Area
Fh = 0
Fv = 0
%delta_l1 = Z(1)
%delta_l2 = Z(2)
%delta_l3 = Z(3)
%delta_h = Z(4)
%delta_v = Z(5)
%P1 = Z(6)
%P2 = Z(7)
%P3 = Z(8)
%alpha_1 = Z(9)
%beta_1 = Z(10)
%gamma_1 = Z(11)
%FInding P1 P2 P3 delta_l1 delta_l2 delta_l3 delta_h delat_v aplha_1 beta_1 gamma_1 values
function [F] = NL_equations(x)
F(1) = (x(1)*cosd(x(9)))+(l1*cosd(x(9)))-(l1*cos(alpha))-x(4)
F(2) = (x(2)*cosd(x(10)))+(l2*cosd(x(10)))-(l2*cos(beta))-x(4)
F(3) = (x(3)*cosd(x(11)))+(x(3)*cosd(x(11)))-(x(3)*cos(gamma))-x(4)
F(4) = (x(1)*sind(x(9)))+(l1*sind(x(9)))-(l1*sind(alpha))-x(5)
F(5) = (x(2)*sind(x(10)))+(l2*sind(x(10)))-(l2*sind(beta))-x(5)
F(6) = (x(3)*sind(x(11)))+(l3*sind(x(11)))-(l3*sind(gamma))-x(5)
F(7) = (x(6)*cosd(x(9)))+(x(7)*cosd(x(10)))+(x(8)*cosd(x(11)))- Fh
F(8) = (x(6)*sind(x(9)))+(x(7)*sind(x(10)))+(x(8)*sind(x(11)))- Fv
F(9) = x(6)-((x(1)*G)/l1)
F(10) = x(7)-((x(2)*G)/l2)
F(11) = x(8)-((x(3)*G)/l3)
F(12) = (x(5)*((cosd(alpha)-cos(x(9)))/(sind(x(9)-alpha))))-x(1)-(x(4)*(sind(alpha)-sind(x(9)))/(sind(x(9)-alpha)))
F(13) = (x(5)*((cosd(beta)-cos(x(10)))/(sind(x(10)-beta))))-x(2)-(x(4)*(sind(beta)-sind(x(10)))/(sind(x(10)-beta)))
F(14) = (x(5)*((cosd(gamma)-cos(x(11)))/(sind(x(11)-gamma))))-x(2)-(x(4)*(sind(gamma)-sind(x(11)))/(sind(x(11)-gamma)))
end
My function file is different from function name. I saw many example they have same name of file and function name but my matlab software does not allow me. It is not an issue.
My Fsolve file code is
clc
setNL= @NLequations
x0 = [0,0,0,0,0,0,0,0,0,0,0]
x = fsolve(setNL, x0)
When I run the folve file it gives me following error
Attempt to execute SCRIPT NLequations as a function:
D:\Aerospace Engineering\Beams Plate and Shell Theory\HW1\NLequations.m
Error in fsolve (line 255)
fuser = feval(funfcn{3},x,varargin{:});
Error in Solution_Nonlinear (line 5)
x = fsolve(setNL, x0)
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
2 个评论
Alex Sha
2022-3-18
编辑:Alex Sha
2022-3-18
14 equations but with 11 unknown parameters, so there should be only approximate solutions, one looks like:
x1: -0.510537655115611
x2: -0.381779180654855
x3: -0.606334009801736
x4: -1.7988680009998
x5: -0.942365788862384
x6: -25526.8827558978
x7: -26995.8647564282
x8: -52510.065566241
x9: 177.806585909659
x10: -184.712630983
x11: -3.48825757205726
Feval:
1: (x1*cosd(x9))+(2*cosd(x9))-(2*cos(30))-x4 = 0.00199405214521198
2: (x2*cosd(x10))+(1.41421356237309*cosd(x10))-(1.41421356237309*cos(45))-x4 = 0.0270064899546518
3: (x3*cosd(x11))+(x3*cosd(x11))-(x3*cos(60))-x4 = 0.0109663233809836
4: (x1*sind(x9))+(2*sind(x9))-(2*sind(30))-x5 = -0.000628096634686659
5: (x2*sind(x10))+(1.41421356237309*sind(x10))-(1.41421356237309*sind(45))-x5 = 0.0271887574354359
6: (x3*sind(x11))+(1.15470053837925*sind(x11))-(1.15470053837925*sind(60))-x5 = -0.090999011308289
7: (x6*cosd(x9))+(x7*cosd(x10))+(x8*cosd(x11))- 0 = 4.24275640398264E-7
8: (x6*sind(x9))+(x7*sind(x10))+(x8*sind(x11))- 0 = 1.41542159326491E-5
9: x6-((x1*100000)/2) = -1.17222953122109E-7
10: x7-((x2*100000)/1.41421356237309) = -7.38902599550784E-7
11: x8-((x3*100000)/1.15470053837925) = 4.37627022620291E-7
12: (x5*((cosd(30)-cos(x9))/(sind(x9-30))))-x1-(x4*(sind(30)-sind(x9))/(sind(x9-30))) = 0.00385210486966825
13: (x5*((cosd(45)-cos(x10))/(sind(x10-45))))-x2-(x4*(sind(45)-sind(x10))/(sind(x10-45))) = -0.00792233330691516
14: (x5*((cosd(60)-cos(x11))/(sind(x11-60))))-x2-(x4*(sind(60)-sind(x11))/(sind(x11-60))) = 0.0355426387726787
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Values 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!