필터 지우기
필터 지우기

I can't execute this code. I am trying to use fsolve to solve my nonlinear equations

조회 수: 2 (최근 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
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
Syed Abdul Rafay Hammad
Syed Abdul Rafay Hammad 2022년 3월 18일
But how did you execute it. I ran the code many time but it didn't work

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by